Submission #1088740

#TimeUsernameProblemLanguageResultExecution timeMemory
1088740IzzyZamjena (COCI18_zamjena)C++14
Compilation error
0 ms0 KiB
def isNumber(a): abc = list("0123456789") if a[0] in abc: return True return False def traverse(start): queue = [start] num = None while queue: a = queue.pop(0) if type(a) == int: if num == None: num = a elif num != a: return False visited[toIndex[a]] = True for i in adj[a]: if not visited[toIndex[i]]: visited[toIndex[i]] = False queue.append(i) return True n = int(input()) arr1 = input().split(' ') arr2 = input().split(' ') adj = {} works = True for i in range(n): if isNumber(arr1[i]) and isNumber(arr2[i]) and arr1[i] != arr2[i]: print('NE') works = False break if isNumber(arr1[i]): arr1[i] = int(arr1[i]) if isNumber(arr2[i]): arr2[i] = int(arr2[i]) if arr1[i] != arr2[i] and arr1[i] in adj: adj[arr1[i]].add(arr2[i]) elif arr1[i] != arr2[i] and arr1[i] not in adj: adj[arr1[i]] = set([arr2[i]]) if arr1[i] != arr2[i] and arr2[i] in adj: adj[arr2[i]].add(arr1[i]) elif arr1[i] != arr2[i] and arr2[i] not in adj: adj[arr2[i]] = set([arr1[i]]) toIndex = {} fromIndex = {} visited = [] if works: visited = [False for i in range(len(adj))] temp = 0 for i in adj: toIndex[i] = temp fromIndex[temp] = i temp += 1 for i in range(len(visited)): if not visited[i]: works = traverse(fromIndex[i]) if not works: print('NE') break if works: print('DA')

Compilation message (stderr)

zamjena.cpp:35:15: warning: multi-character character constant [-Wmultichar]
   35 |         print('NE')
      |               ^~~~
zamjena.cpp:69:23: warning: multi-character character constant [-Wmultichar]
   69 |                 print('NE')
      |                       ^~~~
zamjena.cpp:72:11: warning: multi-character character constant [-Wmultichar]
   72 |     print('DA')
      |           ^~~~
zamjena.cpp:1:1: error: 'def' does not name a type
    1 | def isNumber(a):
      | ^~~
zamjena.cpp:32:1: error: 'works' does not name a type
   32 | works = True
      | ^~~~~
zamjena.cpp:55:1: error: 'fromIndex' does not name a type
   55 | fromIndex = {}
      | ^~~~~~~~~
zamjena.cpp:56:1: error: 'visited' does not name a type
   56 | visited = []
      | ^~~~~~~