Problem p02837 (python)

Fixed submission:
N = int(input())
A = []
lst = [list(format(i, '0%db' % N)) for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = input().split()
        X[i].append(int(tmp_x)-1)
        Y[i].append(tmp_y)

ans = -1

for i in range(2**N):
    flag = 1
    for j in range(N):
        if lst[i][j] == "1":
            for k in range(A[j]):
               if lst[i][X[j][k]] != Y[j][k]:
                   flag = 0
    if flag:
        tmp = 0
        for j in lst[i]:
            if j == "1":
               tmp += 1
        if tmp > ans:
            ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
lst = [list(f"{i:0{N}b}") for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = input().split()
        X[i].append(int(tmp_x)-1)
        Y[i].append(tmp_y)

ans = -1

for i in range(2**N):
    flag = 1
    for j in range(N):
        if lst[i][j] == "1":
            for k in range(A[j]):
               if lst[i][X[j][k]] != Y[j][k]:
                   flag = 0
    if flag:
        tmp = 0
        for j in lst[i]:
            if j == "1":
               tmp += 1
        if tmp > ans:
            ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
# A = []
lst = [list(f"{i:0{N}b}") for i in range(2**N)]
# X = [[] for i in range(N)]
# Y = [[] for i in range(N)]

# for i in range(N):
#     tmp_A = int(input())
#     A.append(tmp_A)
#     for j in range(tmp_A):
#         tmp_x,tmp_y = input().split()
#         X[i].append(int(tmp_x)-1)
#         Y[i].append(tmp_y)

ans = -1

# for i in range(2**N):
#     flag = 1
#     for j in range(N):
#         if lst[i][j] == "1":
#             for k in range(A[j]):
#                if lst[i][X[j][k]] != Y[j][k]:
#                    flag = 0
#     if flag:
#         tmp = 0
#         for j in lst[i]:
#             if j == "1":
#                tmp += 1
#         if tmp > ans:
#             ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
# N = int(input())
# A = []
lst = [list(f"{i:0{N}b}") for i in range(2**N)]
# X = [[] for i in range(N)]
# Y = [[] for i in range(N)]

# for i in range(N):
#     tmp_A = int(input())
#     A.append(tmp_A)
#     for j in range(tmp_A):
#         tmp_x,tmp_y = input().split()
#         X[i].append(int(tmp_x)-1)
#         Y[i].append(tmp_y)

ans = -1

# for i in range(2**N):
#     flag = 1
#     for j in range(N):
#         if lst[i][j] == "1":
#             for k in range(A[j]):
#                if lst[i][X[j][k]] != Y[j][k]:
#                    flag = 0
#     if flag:
#         tmp = 0
#         for j in lst[i]:
#             if j == "1":
#                tmp += 1
#         if tmp > ans:
#             ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
lst = [list(f"{i:0{N}b}") for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

# for i in range(N):
#     tmp_A = int(input())
#     A.append(tmp_A)
#     for j in range(tmp_A):
#         tmp_x,tmp_y = input().split()
#         X[i].append(int(tmp_x)-1)
#         Y[i].append(tmp_y)

ans = -1

# for i in range(2**N):
#     flag = 1
#     for j in range(N):
#         if lst[i][j] == "1":
#             for k in range(A[j]):
#                if lst[i][X[j][k]] != Y[j][k]:
#                    flag = 0
#     if flag:
#         tmp = 0
#         for j in lst[i]:
#             if j == "1":
#                tmp += 1
#         if tmp > ans:
#             ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
lst = [list(f"{i:0{N}b}") for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = input().split()
        X[i].append(int(tmp_x)-1)
        Y[i].append(tmp_y)

ans = -1

# for i in range(2**N):
#     flag = 1
#     for j in range(N):
#         if lst[i][j] == "1":
#             for k in range(A[j]):
#                if lst[i][X[j][k]] != Y[j][k]:
#                    flag = 0
#     if flag:
#         tmp = 0
#         for j in lst[i]:
#             if j == "1":
#                tmp += 1
#         if tmp > ans:
#             ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
lst = [list(f"{i:0{N}b}") for i in range(2**N)]
X = [[] for i in range(N)]
Y = [[] for i in range(N)]

for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = input().split()
        X[i].append(int(tmp_x)-1)
        Y[i].append(tmp_y)

ans = -1

for i in range(2**N):
    flag = 1
    for j in range(N):
        if lst[i][j] == "1":
            for k in range(A[j]):
               if lst[i][X[j][k]] != Y[j][k]:
                   flag = 0
    if flag:
        tmp = 0
        for j in lst[i]:
            if j == "1":
               tmp += 1
        if tmp > ans:
            ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
lst = [format(i, '08b') for i in range(2**N)]
lst.reverse()
X = [[] for i in range(N)]
Y = [[] for i in range(N)]
ans_i = None
ans = 0
for i in range(N):
    tmp_A = int(input())
    A.append(tmp_A)
    for j in range(tmp_A):
        tmp_x,tmp_y = map(int,input().split())
        X[i].append(tmp_x)
        Y[i].append(tmp_y)
for i in lst:
    flag = 0
    PEOPLE = [j for j in i]
    for k in range(N):
        if PEOPLE[k]=="1":
            LEN = len(X[k])
            for l in range(LEN):
                if PEOPLE[X[l]-1]!=Y[l]:
                    flag = 1
    if flag == 0:
        ans_i = i
        break
print(ans_i)
for i in ans_i:
    if i == "1":
        ans+=1
print(ans)