Submission #995222

# Submission time Handle Problem Language Result Execution time Memory
995222 2024-06-08T16:42:03 Z rsinventor Zamjena (COCI18_zamjena) Python 3
14 / 70
18 ms 5252 KB
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
1 Correct 10 ms 2908 KB Output is correct
2 Correct 11 ms 2908 KB Output is correct
3 Correct 10 ms 2908 KB Output is correct
4 Correct 10 ms 2908 KB Output is correct
5 Correct 10 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
2 Incorrect 11 ms 2908 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2908 KB Output is correct
2 Runtime error 12 ms 3032 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 3036 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 5252 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -