#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
string a[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i];
}
string b[n + 1];
for(int i = 1; i <= n; i++){
cin >> b[i];
}
map < string, string > q;
vector < pair < string, string > > e;
for(int i = 1; i <= n; i++){
if(isdigit(a[i][0]) && isdigit(b[i][0])){
if(a[i] != b[i]){
return cout << "NE", 0;
}
}
else if(isdigit(a[i][0]) && !isdigit(b[i][0])){
if(q.find(b[i]) == q.end()){
q[b[i]] = a[i];
}
else if(a[i] != q[b[i]]){
return cout << "NE", 0;
}
}
else if(!isdigit(a[i][0]) && isdigit(b[i][0])){
if(q.find(a[i]) == q.end()){
q[a[i]] = b[i];
}
else if(b[i] != q[a[i]]){
return cout << "NE", 0;
}
}
else{
if(a[i] == b[i]){
continue;
}
e.push_back(make_pair(a[i], b[i]));
}
}
for(auto it : e){
string s = it.first, t = it.second;
if(q.find(s) == q.end() && q.find(t) == q.end()){
}
else if(q.find(s) == q.end() && q.find(t) != q.end()){
q[s] = q[t];
}
else if(q.find(s) != q.end() && q.find(t) == q.end()){
q[t] = q[s];
}
else if(q[s] != q[t]){
return cout << "NE", 0;
}
}
cout << "DA";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
912 KB |
Output is correct |
4 |
Incorrect |
4 ms |
888 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
2292 KB |
Output is correct |
2 |
Correct |
27 ms |
3984 KB |
Output is correct |
3 |
Incorrect |
22 ms |
4588 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |