Problem p02837 (python)

Fixed submission:
#C
n = int(input())
a = []
testimony = [-1]*n
ans = 0
for i in range(n):
    a.append(int(input()))#証言の個数
    l = []
    for j in range(a[i]):
        l.append(list(map(int, input().split())))
    if l != []:
        testimony[i] = l#iの人のa[i]個の証言のリスト
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1 and testimony[n-1-j] != -1:
            for k in range(a[n-1-j]):
                if ((i >> (n - testimony[n-1-j][k][0])) & 1) != testimony[n-1-j][k][1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, str(bin(i)).count('1'))
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n = int(input())
a = []
testimony = [-1]*n
ans = 0
for i in range(n):
    a.append(int(input()))#証言の個数
    l = []
    for j in range(a[i]):
        l.append(list(map(int, input().split())))
    if l != []:
        testimony[i] = l#iの人のa[i]個の証言のリスト
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1 and a[n-1-j] != -1:
            for k in range(a[n-1-j]):
                if ((i >> (n - testimony[n-1-j][k][0])) & 1) = testimony[n-1-j][k][1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, str(bin(i)).count('1'))
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n = int(input())
a = []
testimony = []
ans = 0
for i in range(n):
    a.append(int(input()))#証言の個数
    l = []
    if a[i] == 0:
        l.append([])
        continue
    for j in range(a[i]):
        l.append(list(map(int, input().split())))
    testimony.append(l)#iの人のa[i]個の証言のリスト
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1 and a[n-1-j] != 0:
            for k in range(a[n-1-j]):
                if (i >> (n - testimony[n-1-j][k][0])) != testimony[n-1-j][k][1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, str(bin(i)).count('1'))
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n = int(input())
a = []
testimony = []
ans = 0
for i in range(n):
    a.append(int(input()))#証言の個数
    l = []
    if a[i] == 0:
        l.append(-1)
    for j in range(a[i]):
        l.append(list(map(int, input().split())))
    testimony.append(l)#iの人のa[i]個の証言のリスト
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1 and testimony[n-1-j][k] != -1:
            for k in range(a[n-1-j]):
                if (i >> (n - testimony[n-1-j][k][0])) != testimony[n-1-j][k][1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, str(bin(i)).count('1'))
print(ans)

Buggy submission (verdict: Runtime Error):
#C
n = int(input())
a = []
testimony = []
ans = 0
for i in range(n):
    a.append(int(input()))#証言の個数
    l = []
    if a[i] == 0:
        l.append([0,0])
        continue
    for j in range(a[i]):
        l.append(list(map(int, input().split())))
    testimony.append(l)#iの人のa[i]個の証言のリスト
for i in range(2**n):
    for j in range(n):
        if (i >> j) & 1:
            for k in range(a[n-1-j]):
                if (i >> (n - testimony[n-1-j][k][0])) != testimony[n-1-j][k][1]:
                    break
            else:
                continue
            break
    else:
        ans = max(ans, str(bin(i)).count('1'))
print(ans)