Submission #81849

# Submission time Handle Problem Language Result Execution time Memory
81849 2018-10-27T08:48:14 Z tnbs10 Zamjena (COCI18_zamjena) Python 3
14 / 70
48 ms 4976 KB
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
1 Correct 25 ms 3428 KB Output is correct
2 Correct 26 ms 3488 KB Output is correct
3 Correct 35 ms 3664 KB Output is correct
4 Correct 28 ms 3676 KB Output is correct
5 Correct 24 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 3736 KB Output is correct
2 Incorrect 25 ms 3736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 29 ms 3736 KB Output is correct
2 Correct 25 ms 3736 KB Output is correct
3 Runtime error 27 ms 3736 KB Execution failed because the return code was nonzero
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3736 KB Output is correct
2 Runtime error 27 ms 3736 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 4976 KB Output isn't correct
2 Halted 0 ms 0 KB -