def provjera(L1,L2):
A,B=[],[]
for i in range(len(L1)):
if L1[i]!=L2[i]:
A.append(L1[i])
B.append(L2[i])
return A,B
def main():
N=int(input())
L=input().split()
L2=input().split()
#print('L:',L,'L2:',L2)
L,L2=provjera(L,L2)
#print('NAKON L:',L,'L2:',L2)
while L!=[]:
for i in range(len(L)):
#print ('L[i]:',L[i],'L2[i]:',L2[i])
if L[i].isdigit() and L2[i].isdigit() and L[i]!=L2[i]:
La,Lb=provjera(L,L2)
if La!=[]:
#print('PR NE L:',L,'L2:',L2)
print("NE")
return
elif (L[i].isdigit() is not True) and L2[i].isdigit():
b,a=L2[i],L[i]
for j in range(len(L)):
if L[j]==a: L[j]=b
if L2[j]==a: L2[j]=b
elif (L2[i].isdigit() is not True) and L[i].isdigit():
a,b=L2[i],L[i]
for j in range(len(L)):
if L[j]==a: L[j]=b
if L2[j]==a: L2[j]=b
elif (L[i].isdigit() is not True) and (L2[i].isdigit() is not True):
#print("uslaaaa")
a,b=L2[i],L[i]
for j in range(len(L)):
if L[j]==a: L[j]=b
if L2[j]==a: L2[j]=b
#print('usla i ucinila L:',L,'L2:',L2)
#print('L:',L,'L2:',L2)
L,L2=provjera(L,L2)
#print('NAKON L:',L,'L2:',L2)
print("DA")
return
main()
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
3428 KB |
Output is correct |
2 |
Correct |
26 ms |
3428 KB |
Output is correct |
3 |
Correct |
25 ms |
3428 KB |
Output is correct |
4 |
Correct |
25 ms |
3428 KB |
Output is correct |
5 |
Correct |
25 ms |
3428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
3428 KB |
Output is correct |
2 |
Correct |
25 ms |
3428 KB |
Output is correct |
3 |
Correct |
28 ms |
3428 KB |
Output is correct |
4 |
Correct |
25 ms |
3400 KB |
Output is correct |
5 |
Correct |
29 ms |
3428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
35 ms |
3420 KB |
Output is correct |
2 |
Correct |
25 ms |
3440 KB |
Output is correct |
3 |
Correct |
25 ms |
3428 KB |
Output is correct |
4 |
Correct |
25 ms |
3428 KB |
Output is correct |
5 |
Correct |
29 ms |
3428 KB |
Output is correct |
6 |
Correct |
26 ms |
3428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
215 ms |
3484 KB |
Output is correct |
2 |
Correct |
170 ms |
3428 KB |
Output is correct |
3 |
Execution timed out |
1058 ms |
3796 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1066 ms |
4824 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |