#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <vector>
#include <string>
using namespace std;
int n, sol;
string s1[500003], s2[500003], ts;
int main(){
cin >> n;
for (int i= 0; i < n; i++){
cin >> s1[i];
}
for (int i= 0; i < n; i++){
cin >> s2[i];
}
for (int i= 0; i < n; i++){
if (s1[i][0] <= 57 and s2[i][0] <= 57){
if (s1[i] != s2[i])
sol = 1;
}
if (s1[i][0] <= 57 and s2[i][0] > 57){
ts = s2[i];
for (int j = 0; j < n; j++){
if (s1[j] == ts){
s1[j] = s1[i];
}
if (s2[j] == ts){
s2[j] = s1[i];
}
}
}
if (s1[i][0] > 57 and s2[i][0] <= 57){
ts = s1[i];
for (int j = 0; j < n; j++){
if (s1[j] == ts){
s1[j] = s2[i];
}
if (s2[j] == ts){
s2[j] = s2[i];
}
}
}
}
for (int i= 0; i < n; i++){
if (s1[i][0] <= 57 and s2[i][0] <= 57){
if (s1[i] != s2[i])
sol = 1;
}
if (s1[i][0] <= 57 and s2[i][0] > 57){
ts = s2[i];
for (int j = 0; j < n; j++){
if (s1[j] == ts){
s1[j] = s1[i];
}
if (s2[j] == ts){
s2[j] = s1[i];
}
}
}
if (s1[i][0] > 57 and s2[i][0] <= 57){
ts = s1[i];
for (int j = 0; j < n; j++){
if (s1[j] == ts){
s1[j] = s2[i];
}
if (s2[j] == ts){
s2[j] = s2[i];
}
}
}
}
for (int i= 0; i < n; i++){
if (s1[i][0] <= 57 and s2[i][0] <= 57){
if (s1[i] != s2[i])
sol = 1;
}
if (s1[i][0] <= 57 and s2[i][0] > 57){
ts = s2[i];
for (int j = 0; j < n; j++){
if (s1[j] == ts){
s1[j] = s1[i];
}
if (s2[j] == ts){
s2[j] = s1[i];
}
}
}
if (s1[i][0] > 57 and s2[i][0] <= 57){
ts = s1[i];
for (int j = 0; j < n; j++){
if (s1[j] == ts){
s1[j] = s2[i];
}
if (s2[j] == ts){
s2[j] = s2[i];
}
}
}
}
for (int i= 0; i < n; i++){
if (s1[i] != s2[i] and s1[i][0] <= 57 and s2[i][0] <= 57){
sol = 1;
}
}
if (sol == 1){
cout << "NE";
}else{
cout << "DA";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
31608 KB |
Output is correct |
2 |
Correct |
31 ms |
31608 KB |
Output is correct |
3 |
Correct |
30 ms |
31608 KB |
Output is correct |
4 |
Correct |
31 ms |
31608 KB |
Output is correct |
5 |
Correct |
31 ms |
31580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
31608 KB |
Output is correct |
2 |
Correct |
31 ms |
31608 KB |
Output is correct |
3 |
Correct |
31 ms |
31576 KB |
Output is correct |
4 |
Correct |
31 ms |
31608 KB |
Output is correct |
5 |
Correct |
30 ms |
31608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
31608 KB |
Output is correct |
2 |
Correct |
31 ms |
31636 KB |
Output is correct |
3 |
Correct |
38 ms |
31608 KB |
Output is correct |
4 |
Correct |
42 ms |
31608 KB |
Output is correct |
5 |
Correct |
31 ms |
31736 KB |
Output is correct |
6 |
Incorrect |
37 ms |
31608 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
31608 KB |
Output is correct |
2 |
Correct |
43 ms |
31608 KB |
Output is correct |
3 |
Correct |
97 ms |
31736 KB |
Output is correct |
4 |
Correct |
71 ms |
31608 KB |
Output is correct |
5 |
Correct |
108 ms |
31608 KB |
Output is correct |
6 |
Correct |
96 ms |
31604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
811 ms |
31668 KB |
Output is correct |
2 |
Execution timed out |
1071 ms |
31732 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |