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):
from itertools import product
n = int(input())
a = []
xy = []
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xy.append(list(map(int,input().split())) ) 

cnt = 0
for bit in product([0,1],repeat=n):
    fl = [1] * n 
    hantei = True
    for i,j in enumerate(bit):
        if j == 1:
            fl[i] = 0
    for k in range(n):
        for l in range(a[k]):
            
            if fl[k] == 1:
                if fl[xy[l][0]-1] != xy[l][1]:
                    hantei = False
            elif fl[k] == 0:
                if fl[xy[l][0]-1] == xy[l][1]:
                    hantei = False
        if hantei:
            cnt = max(cnt,sum(fl))

print(cnt)            

from itertools import product
n = int(input())
a = []
xy = []
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xy.append(list(map(int,input().split())) ) 


cnt = 0 
for bit in product([0,1],repeat=n):
    fl = [1] * n 
    for i,j in enumerate(bit):
        hantei = True
        if j == 1:
            fl[i] = 0
    for k in range(n):
        for l in range(a[k]):
            
            if fl[k] == 1:
              if fl[xy[l][0]-1] != xy[l][1]:
                hantei = False
            else:
                if fl[xy[l][0]-1] == xy[l][1]:
                    hantei = False
    if hantei:
        cnt = max(cnt,fl.count(1))

print(cnt)                
  


from itertools import product
n = int(input())
a = []
xy = []
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xy.append(list(map(int,input().split())) ) 


cnt = 0 
for bit in product([0,1],repeat=n):
    fl = [1] * n 
    for i,j in enumerate(bit):
        hantei = True
        if j == 1:
            fl[i] = 0
    for k in range(n):
        for l in range(a[k]):
            
            if fl[k] == 1:
              if fl[xy[l][0]-1] != xy[l][1]:
                hantei = False
            else:
                if fl[xy[l][0]-1] == xy[l][1]:
                    hantei = False
    if hantei:
        cnt = max(cnt,fl.count(1))

print(cnt)                
  


from itertools import product
n = int(input())
a = []
xy = []
for i in range(n):
    a.append(int(input()))
    for j in range(a[i]):
        xy.append(list(map(int,input().split())) ) 

cnt = 0
for bit in product([0,1],repeat=n):
    fl = [1] * n 
    hantei = True
    for i,j in enumerate(bit):
        if j == 1:
            fl[i] = 0
    counter = 0
    for k in range(n):
        for l in range(a[k]):
            
            if fl[k] == 1 and fl[xy[counter][0]-1] != xy[counter][1]:
                hantei = False
                break
            counter += 1
    if hantei:
        cnt = max(cnt,sum(fl))

print(cnt)                
  


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted