Submission #995224

#TimeUsernameProblemLanguageResultExecution timeMemory
995224rsinventorZamjena (COCI18_zamjena)Cpython 3
42 / 70
23 ms6632 KiB
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")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...