Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
lis = [0]*N
SC = []
ERROR = False
for _ in range(M):
  sc = list(map(int, input().split()))
  SC.append(sc)
for i in range(len(SC)-1):
  for j in range(i+1,len(SC)):
    if SC[i][0] == SC[j][0] and SC[i][1] != SC[j][1]:
      ERROR = True
for i in range(len(SC)):
  if N > 1 and SC[i][0] == 1 and SC[i][1] == 0:
    ERROR = True
if ERROR:
  print(-1)
else:
  output = ''
  for i in range(M):
    lis[SC[i][0]-1] = SC[i][1]
  if N > 1 and lis[0] == 0:
    lis[0] = 1
  for i in range(N):
    output += str(lis[i])
  print(int(output))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = [0]*N
SC = []
ERROR = False
for _ in range(M):
  sc = list(map(int, input().split()))
  SC.append(sc)
for i in range(len(SC)-1):
  for j in range(i+1,len(SC)):
    if SC[i][0] == SC[j][0] and SC[i][1] != SC[j][1]:
      ERROR = True
if ERROR:
  print(-1)
else:
  output = ''
  for i in range(M):
    lis[SC[i][0]-1] = SC[i][1]
  if N > 1 and lis[0] == 0:
    print(-1)
  else:
    for i in range(M):
      output += str(lis[i])
    print(int(output))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = [0]*N
SC = []
ERROR = False
for _ in range(N):
  sc = list(map(int, input().split()))
  SC.append(sc)
for i in range(len(SC)-1):
  for j in range(i+1,len(SC)):
    if SC[i][0] == SC[j][0] and SC[i][1] != SC[j][1]:
      ERROR = True
if ERROR:
  print('-1')
else:
  output = ''
  if N > 1 and lis[0] == '0':
    print('-1')
  else:
    for i in range(len(SC)):
      lis[SC[i][0]-1] = SC[i][1]
    for i in range(N):
      output += str(lis[i])
    print(output)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = [0]*N
SC = []
ERROR = False
for _ in range(N):
  sc = list(map(int, input().split()))
  SC.append(sc)
for i in range(len(SC)-1):
  for j in range(i+1,len(SC)):
    if SC[i][0] == SC[j][0] and SC[i][1] != SC[j][1]:
      ERROR = True
if ERROR:
  print('-1')
else:
  output = ''
  for i in range(len(SC)):
    lis[SC[i][0]-1] = SC[i][1]
  for i in range(N):
    output += str(lis[i])
  if lis[0] == '0':
    print('-1')
  else:
    print(output)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = [0]*N
S = []
C = []
ERROR = False
for _ in range(N):
  s,c = map(int, input().split())
  S.append(s)
  C.append(c)
for i in range(len(S)-1):
  for j in range(i+1,len(S)):
    if S[i] == S[j] and C[i] != C[j]:
      ERROR = True
if ERROR:
  print('-1')
else:
  output = ''
  for i in range(len(S)):
    lis[S[i]-1] = C[i]
  for i in range(N):
    output += str(lis[i])
  if lis[0] == '0':
    print('-1')
  else:
    print(output)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = [0]*N
S = []
C = []
ERROR = False
for _ in range(N):
  s,c = map(int, input().split())
  S.append(s)
  C.append(c)
for i in range(len(S)-1):
  for j in range(i+1,len(S)):
    if S[i] == S[j] and C[i] != C[j]:
      ERROR = True
if ERROR:
  print(-1)
else:
  output = ''
  for i in range(len(S)):
    lis[S[i]-1] = C[i]
  for i in range(N):
    output += str(lis[i])
  if lis[0] == '0':
    print(-1)
  else:
    print(output)