# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
637540 | NotLinux | Zamjena (COCI18_zamjena) | C++14 | 6 ms | 1956 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* author: NotLinux
* created: 02.09.2022 ~ 14:19:34
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
#include "/home/notlinux/debug.h"
#else
#define debug(x...) void(37)
#endif
#define sos(x) dict.find(fond(x)) != dict.end()
int n;
map < string , string > par;
map < string , string > mpa;
string fond(string str){
if(par[str] == str)return str;
if(mpa.find(str) == mpa.end()){
par[str] = str;
mpa[str] = 1;
}
par[str] = fond(par[str]);
return par[str];
}
void merge(string a , string b){
par[fond(a)] = fond(b);
}
bool nuum(string str){
for(auto itr : str)if(itr < '0' or itr > '9')return 0;
return 1;
}
void solve(){
cin >> n;
vector < string > a(n) ,b(n);
map < string , int > dict;
for(auto &inp : a)cin >> inp;
for(auto &inp : b)cin >> inp;
for(int i = 0;i<n;i++){
if(a[i] == b[i])continue;
if(nuum(a[i]) and nuum(b[i])){
cout << "NE" << endl;
return;
}
else if(nuum(a[i]) and nuum(b[i])==0){
if(sos(b[i])==0){
dict[fond(b[i])] = stoi(a[i]);
}
if(dict[fond(b[i])] != stoi(a[i])){
cout << "NE" << endl;
return;
}
}
else if(nuum(a[i])==0 and nuum(b[i])){
if(sos(a[i])==0){
dict[fond(a[i])] = stoi(b[i]);
}
if(dict[fond(a[i])] != stoi(b[i])){
cout << "NE" << endl;
return;
}
}
else {
if((sos(a[i])==0 and sos(b[i])==0) and (dict[a[i]] != dict[b[i]])){
cout << "NE" << endl;
return;
}
merge(a[i],b[i]);
}
}
cout << "DA" << endl;
}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);
int tt=1;
//cin >> tt;
while(tt--)solve();
}
컴파일 시 표준 에러 (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... |