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 = int(input())
a = list(map(str, input().split()))
b = list(map(str, input().split()))
# print(a)
# print(b)
c = {}
flag = True
for i in range(n):
if a[i] == b[i]:
continue
if a[i][0] in '0123456789' and b[i][0] in '0123456789' and not(a[i] == b[i]):
flag = False
break
if a[i][0] in '0123456789':
a[i] = int(a[i])
if b[i] in c:
if a[i] == c[b[i]]:
continue
else:
flag = False
break
else:
c[b[i]] = a[i]
elif b[i][0] in '0123456789':
b[i] = int(b[i])
if a[i] in c:
if b[i] == c[a[i]]:
continue
else:
flag = False
break
else:
c[a[i]] = b[i]
else:
if (a[i] in c) and (not(b[i] in c)):
c[b[i]] = c[a[i]]
elif (not(a[i] in c)) and (b[i] in c):
c[a[i]] = c[b[i]]
elif (a[i] in c) and (b[i] in c):
if c[a[i]] == b[a[i]]:
continue
else:
flag = False
break
else:
continue
if flag:
print("DA")
else:
print("NE")
# print(c)
# | 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... |