Problem p02837 (python)

Fixed submission:
N = int(input())

#人が一人しかいないとき
if N == 1:
    print(1)
    exit()

#人が2人以上いるとき
#N人それぞれが正直か不誠実かの全パターンを生成
H = []
for i in range(2**N):
    S = str(bin(i))
    H.append(S[2:].zfill(N))
#入力を受け取る
IXY = []
for i in range(N):
    t = int(input())
    for j in range(t):
        x,y = map(int,input().split())
        #i番目の人が「x番目の人はyである」と証言
        IXY.append([i,x,y])

ans = 0
for h in H:
    cnt = h.count("1")
    for ixy in IXY:
        i,x,y = ixy[0],ixy[1]-1,ixy[2]
        if h[i] == "1" and h[x] != str(y):
            cnt = 0
            break
    ans = max(ans,cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
#人が一人しかいないとき
if N == 1:
    print(1)
    exit()

#人が2人以上いるとき
l = [0,1]
H = []
#N人それぞれが正直か不誠実かの全パターンを生成
for i in range(2**N+1):
    S = str(bin(i)).zfill(N)
    H.append(S[2:].zfill(N))
#入力を受け取る
IXY = []
for i in range(1,N+1):
    t = int(input())
    for j in range(t):
        x,y = map(int,input().split())
        #i番目の人が「x番目の人はyである」と証言
        IXY.append([i,x,y])

ANS = []
for h in H:
    flg = True
    for ixy in IXY:
        i,x,y = ixy[0]-1,ixy[1]-1,ixy[2]
        if h[i] == "1" and h[x] != str(y):
            flg = False
            break
    if flg:ANS.append(h)

ans = 0
for a in ANS:
    ans = max(a.count("1"),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print(1)
    exit()
A = [0 for _ in range(N+1)]
l = [0,1]
H = []
for i in range(2**N):
    S = str(bin(i)).zfill(N)
    H.append(S[2:].zfill(N))
IXY = []
for i in range(1,N+1):
    A[i] = int(input())
    if A[i] == 0:
        continue
    for j in range(A[i]):
        x,y = map(int,input().split())
        IXY.append([i,x,y])
ANS = []
for h in H:
    for ixy in IXY:
        flg = True
        i,x,y = ixy[0]-1,ixy[1]-1,ixy[2]
        if h[i] == "1":
            if h[x] != str(y):
                flg = False
                break
    if flg:l.append(ANS.append(h))
ans = 0
for a in ANS:
    ans = max(a.count("1"),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 1:
    print(1)
    exit()
A = [0 for _ in range(N+1)]
l = [0,1]
H = []
for i in range(2**N):
    S = str(bin(i)).zfill(N)
    H.append(S[2:].zfill(N))
IXY = []
for i in range(1,N+1):
    A[i] = int(input())
    for j in range(A[i]):
        x,y = map(int,input().split())
        IXY.append([i,x,y])
ANS = []
for h in H:
    for ixy in IXY:
        flg = True
        i,x,y = ixy[0]-1,ixy[1]-1,ixy[2]
        if h[i] == "1":
            if h[x] != str(y):
                flg = False
                break
    if flg:l.append(ANS.append(h))
ans = 0
for a in ANS:
    ans = max(a.count("1"),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
if N == 1:
    k,l = map(int,input().split())
    if l == 1:
        print(1)
    else:
        print(0)
    exit()
A = [0 for _ in range(N+1)]
l = [0,1]
H = []
for i in range(2**N):
    S = str(bin(i)).zfill(N)
    H.append(S[2:].zfill(N))
#H = list(combinations_with_replacement(l, N))
IXY = []
for i in range(1,N+1):
    A[i] = int(input())
    for j in range(A[i]):
        x,y = map(int,input().split())
        IXY.append([i,x,y])
ANS = []
for h in H:
    for ixy in IXY:
        flg = True
        i,x,y = ixy[0]-1,ixy[1]-1,ixy[2]
        if h[i] == "1":
            if h[x] != str(y):
                flg = False
                break
    if flg:l.append(ANS.append(h))
ans = 0
for a in ANS:
    ans = max(a.count("1"),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
if N == 1:
    k,l = map(int,input())
    if l == 1:
        print(1)
    else:
        print(0)
A = [0 for _ in range(N+1)]
l = [0,1]
H = []
for i in range(2**N):
    S = str(bin(i)).zfill(N)
    H.append(S[2:].zfill(N))
#H = list(combinations_with_replacement(l, N))
IXY = []
for i in range(1,N+1):
    A[i] = int(input())
    for j in range(A[i]):
        x,y = map(int,input().split())
        IXY.append([i,x,y])
ANS = []
for h in H:
    for ixy in IXY:
        flg = True
        i,x,y = ixy[0]-1,ixy[1]-1,ixy[2]
        if h[i] == "1":
            if h[x] != str(y):
                flg = False
                break
    if flg:l.append(ANS.append(h))
ans = 0
for a in ANS:
    ans = max(a.count("1"),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
A = [0 for _ in range(N+1)]
l = [0,1]
H = []
for i in range(2**N):
    S = str(bin(i)).zfill(N)
    H.append(S[2:].zfill(N))
IXY = []
for i in range(1,N+1):
    A[i] = int(input())
    for j in range(A[i]):
        x,y = map(int,input().split())
        IXY.append([i,x,y])
ANS = []
for h in H:
    for ixy in IXY:
        flg = True
        i,x,y = ixy[0]-1,ixy[1]-1,ixy[2]
        if h[i] == "1":
            if h[x] != str(y):
                flg = False
                break
    if flg:l.append(ANS.append(h))
ans = 0
for a in ANS:
    ans = max(a.count("1"),ans)
print(ans)