n = eval(input());
a = input().split(" ")
b = input().split(" ")
cnt = set()
def dfs(root):
if root.isnumeric():
cnt.add(root)
return
visited[root] = True
for a in adj[root]:
if not visited[a]:
dfs(a)
visited = {}
adj = {}
for i in range(n):
visited[a[i]] = False
visited[b[i]] = False
if(a[i] not in adj.keys()):
adj[a[i]] = []
if(b[i] not in adj.keys()):
adj[b[i]] = []
adj[a[i]].append(b[i])
adj[b[i]].append(a[i])
flag = True;
for i in range(n):
if a[i].isnumeric() and b[i].isnumeric() and a[i]!=b[i]:
flag = False
break
if(visited[a[i]]==False):
cnt = set()
dfs(a[i])
if len(cnt)>1:
flag = False
break
if flag:
print("DA")
else:
print("NE")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
2908 KB |
Output is correct |
2 |
Correct |
11 ms |
3064 KB |
Output is correct |
3 |
Correct |
10 ms |
2908 KB |
Output is correct |
4 |
Correct |
10 ms |
2832 KB |
Output is correct |
5 |
Correct |
11 ms |
2908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
2980 KB |
Output is correct |
2 |
Correct |
14 ms |
3068 KB |
Output is correct |
3 |
Correct |
11 ms |
2908 KB |
Output is correct |
4 |
Correct |
11 ms |
3060 KB |
Output is correct |
5 |
Correct |
11 ms |
2908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
2908 KB |
Output is correct |
2 |
Correct |
10 ms |
3072 KB |
Output is correct |
3 |
Incorrect |
15 ms |
2836 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
3376 KB |
Output is correct |
2 |
Correct |
14 ms |
3240 KB |
Output is correct |
3 |
Correct |
14 ms |
3788 KB |
Output is correct |
4 |
Correct |
15 ms |
3932 KB |
Output is correct |
5 |
Correct |
18 ms |
3816 KB |
Output is correct |
6 |
Correct |
16 ms |
3832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
6632 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |