This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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
adj[a[i]] = b[i]
adj[b[i]] = 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")
# | 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... |