Problem: There are N people numbered 1 to N. Each of them is either an _honest_ person whose testimonies are always correct or an _unkind_ person whose testimonies may be correct or not.  Person i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} = 1, the testimony says Person x_{ij} is honest; if y_{ij} = 0, it says Person x_{ij} is unkind.  How many honest persons can be among those N people at most?

Submission attempts (in order):
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    flag = True
    for j in range(N):
        hon = [0]*N
        if (i>>j)&1 == 1:
            hon[j] = 1
            for k in range(N):
                if tes[j][k] == -1:
                    continue
                if tes[j][k] != hon[k]:
                    flag = False
                    break
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[] for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i].append((x-1,y))

cnt = 0
for i in range(2**N):
    flag = True
    for j in range(N):
        if (i>>j)&1 == 1:
            for x,y in tes[j]:
                if (i>>x)&1 != y:
                    flag = False
                    break
    if flag:
        cnt = max(cnt,bin(i)[2:].count(1))
print(cnt)

#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[0]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if hon[j]:
            for k in range(N):
                if tes[j][k] != hon[k]:
                    flag = False
                    break
        if not flag:
            break
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[-1]*N for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i][x-1] = y

cnt = 0
for i in range(2**N):
    hon = [0]*N
    for j in range(N):
        if (i>>j)&1:
            hon[j] = 1
    flag = True
    for j in range(N):
        if hon[j]:
            for k in range(N):
                if tes[j][k] != hon[k]:
                    flag = False
                    break
        if not flag:
            break
    if flag:
        cnt = max(cnt,hon.count(1))
print(cnt)

#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
tes = [[] for i in range(N)]
for i in range(N):
    A = int(readline())
    for j in range(A):
        x,y = map(int,readline().rstrip().split())
        tes[i].append((x-1,y))

cnt = 0
for i in range(2**N):
    flag = True
    for j in range(N):
        if (i>>j)&1 == 1:
            for x,y in tes[j]:
                if (i>>x)&1 != y:
                    flag = False
                    break
    if flag:
        cnt = max(cnt,bin(i)[2:].count("1"))
print(cnt)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted