답안 #995149

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995149 2024-06-08T14:03:11 Z rsinventor Zamjena (COCI18_zamjena) C++17
컴파일 오류
0 ms 0 KB
n = eval(input());
a = input().split(" ")
b = input().split(" ")
for i in range(n):
    if a[i].isnumeric():
        a[i] = eval(a[i])
    if b[i].isnumeric():
        b[i] = eval(b[i])

variables = {}
flag = True;
equals = {}
for i in range(n):
    if a[i]!=b[i] and type(a[i])==str and type(b[i])==str:
        if a[i] in variables.keys() and b[i] in variables.keys():
            if(variables[a[i]]!=variables[b[i]]):
                flag = False
                break
        elif a[i] in variables.keys():
             variables[b[i]] = variables[a[i]]
        elif b[i] in variables.keys():
            variables[a[i]] = variables[b[i]]  
        else:
            equals[a[i]] = b[i]
    elif a[i]!=b[i] and type(a[i])==str:
        if a[i] in variables.keys():
            if(variables[a[i]]!=b[i]):
                flag = False
                break
        else:
            variables[a[i]] = b[i]
    elif a[i]!=b[i] and type(b[i])==str:
        if b[i] in variables.keys():
            if(variables[b[i]]!=a[i]):
                flag = False
                break
        else:
            variables[b[i]] = a[i]
for k in equals.keys():
    if(k in variables.keys() and equals[k] in variables.keys() and variables[k]!=variables[equals[k]]):
        flag = False
        break
        
if flag:
    print("DA")
else:
    print("NE")

Compilation message

zamjena.cpp:1:1: error: 'n' does not name a type
    1 | n = eval(input());
      | ^
zamjena.cpp:2:1: error: 'a' does not name a type
    2 | a = input().split(" ")
      | ^
zamjena.cpp:11:1: error: 'flag' does not name a type
   11 | flag = True;
      | ^~~~
zamjena.cpp:12:1: error: 'equals' does not name a type
   12 | equals = {}
      | ^~~~~~
zamjena.cpp:13:1: error: expected unqualified-id before 'for'
   13 | for i in range(n):
      | ^~~