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):
n = int(input())
Asgs = list()

def get_sgs(an):
    sgs = [list(map(int, input().split())) for i in range(an)]
    return sgs


for i in range(n):
    an = int(input())
    Asgs.append(get_sgs(an))

bits = [1] * n
end = False
# print(Asgs)
# sys.exit()
last_bits = [2] * n

cnt = 0
while cnt < 5:
    for i in range(n):
        
        
        for j in range(len(Asgs[i])):
            
            if bits[i] == 1 and Asgs[i][j][1] == 0 and bits[Asgs[i][j][0]-1] ==1:
                
                
                bits[Asgs[i][j][0]-1] = 0
                """
                bits[i] = 0
                or
                bits[Asgs[i][j][0]-1] = 0
                """
                # print(i, j)
            
            if bits[i] == 1 and bits[Asgs[i][j][0]-1] == 0 and Asgs[i][j][1] == 1:
                bits[i] = 0
                # print('mj11')
            
    if last_bits == bits:
        cnt += 1
    last_bits = bits
        
# print(bits)
print(sum(bits))


n = int(input())
Asgs = list()

def get_sgs(an):
    sgs = [list(map(int, input().split())) for i in range(an)]
    return sgs


for i in range(n):
    an = int(input())
    Asgs.append(get_sgs(an))

bits = [1] * n
end = False
# print(Asgs)
# sys.exit()
last_bits = [2] * n

cnt = 0
while cnt < 5:
    for i in range(n):
        
        
        for j in range(len(Asgs[i])):
            
            if bits[i] == 1 and Asgs[i][j][1] == 0 and bits[Asgs[i][j][0]-1] ==1:
                
                
                bits[Asgs[i][j][0]-1] = 0
                """
                bits[i] = 0
                or
                bits[Asgs[i][j][0]-1] = 0
                """
                # print(i, j)
            
            if bits[i] == 1 and bits[Asgs[i][j][0]-1] == 0 and Asgs[i][j][1] == 1:
                bits[i] = 0
                # print('mj11')
            
    if last_bits == bits:
        cnt += 1
    last_bits = bits
        
# print(bits)
print(sum(bits))

import sys 

n = int(input())
Asgs = list()

def get_sgs(an):
    sgs = [list(map(int, input().split())) for i in range(an)]
    return sgs


for i in range(n):
    an = int(input())
    Asgs.append(get_sgs(an))

bits = [1] * n
end = False
# print(Asgs)
# sys.exit()
last_bits = [2] * n

cnt = 0
while cnt < 5:
    for i in range(n):
        
        
        for j in range(len(Asgs[i])):
            
            if bits[i] == 1 and Asgs[i][j][1] == 0 and bits[Asgs[i][j][0]-1] ==1:
                
                
                bits[Asgs[i][j][0]-1] = 0
                """
                bits[i] = 0
                or
                bits[Asgs[i][j][0]-1] = 0
                """
                # print(i, j)
            
            if bits[i] == 1 and bits[Asgs[i][j][0]-1] == 0 and Asgs[i][j][1] == 1:
                bits[i] = 0
                # print('mj11')
            
    if last_bits == bits:
        cnt += 1
    last_bits = bits
        
# print(bits)
print(sum(bits))

n = int(input())
Asgs = list()

def get_sgs(an):
    sgs = [list(map(int, input().split())) for i in range(an)]
    return sgs


for i in range(n):
    an = int(input())
    Asgs.append(get_sgs(an))

bits = list()
for i in range(2**n):
    bits.append(list(map(int, list(bin(i)[2::].zfill(n)))))


cnt = 0
ps = list()
is_break = False
# print(bits)
# print(Asgs)

for i in range(2**n):
    for j in range(n):
        
        
        for k in range(len(Asgs[j])):
            
            if bits[i][j] == 1 and Asgs[j][k][1] == 1 and bits[i][Asgs[j][k][0]-1] == 0:
                
                bits[i] = [0]*n
            elif bits[i][j] == 1 and Asgs[j][k][1] == 0 and bits[i][Asgs[j][k][0]-1] == 1:
                bits[i] = [0]*n
                
    if bits[i] == [1,1,1]:
        print(i,j,k)
        print('ghogegegaega')
    ps.append(sum(bits[i]))
    

print(max(ps))
#print(ps)
#print(Asgs)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted