This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
int n;
vector <string> a, b;
bool num(string &x){
return '0' <= x[0] && x[0] <= '9';
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
a.resize(n);
for(auto &i : a) cin >> i;
b.resize(n);
for(auto &i : b) cin >> i;
map <string, string> m;
for(int itt = 0 ; itt < 2 ; itt++){
for(int i = 0 ; i < n ; i++){
int g = num(a[i]), h = num(b[i]);
if(g && h){
if(a[i] != b[i]) finish("NE");
}
else if(g && !h){
if(m.count(b[i]) && m[b[i]] != a[i]) finish("NE");
m[b[i]] = a[i];
}
else if(!g && h){
if(m.count(a[i]) && m[a[i]] != b[i]) finish("NE");
m[a[i]] = b[i];
}
else{
g = m.count(a[i]);
h = m.count(b[i]);
if(g && h && m[a[i]] != m[b[i]]) finish("NE");
if(!g && h) m[a[i]] = m[b[i]];
if(g && !h) m[b[i]] = m[a[i]];
}
}
}
cout << "DA" << endl;
}
# | 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... |