# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89820 | tpoppo | Zamjena (COCI18_zamjena) | C++14 | 61 ms | 2580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
void NE(){
cout<<"NE";
exit(0);
}
void DA(){
cout<<"DA";
exit(0);
}
vector<string> a,b;
map<string,string> parent;
map<string,int> value;
string find(string a){
if(parent[a] == a) return a;
return parent[a] = find(parent[a]);
}
void merge(string a,string b){
a = find(a);
b = find(b);
if(value[a] == -1e9 || value[b] == -1e9 || value[a] == value[b]){
parent[b] = a;
}else{
NE();
}
}
int main() {
ll n;
ll sn = 0;
cin.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
a.resize(n);
b.resize(n);
for(auto&el:a){
cin>>el;
value[el] = -1e9;
parent[el] = el;
}
for(auto&el:b){
cin>>el;
value[el] = -1e9;
parent[el] = el;
}
for(int i=0;i<n;i++){
if(isdigit(a[i][0]) && isdigit(b[i][0])){
if(a[i] != b[i]){
NE();
}
}else if(isdigit(a[i][0]) || isdigit(b[i][0])){
if(isdigit(a[i][0])) swap(a[i],b[i]);
int c = stoi(b[i]);
if(value[a[i]] != c && value[a[i]] != -1e9){
NE();
}
value[a[i]] = c;
}else{
merge(a[i],b[i]);
}
}
DA();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |