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())

Honests =['']*N

for i in range(N):
    
    A_i = int(input())
    
    for j  in range(A_i):

        x_ij,y_ij = map(int,input().split())
        x_ij=x_ij-1

        if y_ij==0:
            Honests[x_ij] += '0'
        else:
            Honests[x_ij] += '1'

print(Honests) 

cnt=0
cnt_0=0
cnt_un=0

for i in Honests:
    cnt += i.count('1')
    cnt_0 += i.count('0')
    if '' == i:
        cnt_un+=1

if cnt==0 and cnt_0>0:
    print(0)
    exit(0)

print(cnt-(cnt_0-cnt_un))



N=int(input())

A=[]
test = []
for i in range(N):
    A_i= int(input())
    A.append(A_i)
    for j in range(A_i):
        x,y= map(int,input().split())

        test.append([x-1,y])

print(A)
print(test)

total = 0
for i in range(2**N):
    
    Honests=[0]*N
    
    for j in range(N):

        if (i>>j) &1:

            A_j = A[j]
            
            for k in range(A_j):
                x,y =test[j][0],test[j][1]

                x-=1
                if y ==1:
                    Honests[x]=1
                else:
                    Honests[x]=0
        else:
            A_j=A[j]

            for k in range(A_j):
                x,y =test[j][0],test[j][1]

                x-=1
                if y ==1:
                    Honests[x]=0
                else:
                    Honests[x]=1
            
    total = max(total,max(Honests))

print(total)




N=int(input())

A=[]
test = []
for i in range(N):
    A_i= int(input())
    A.append(A_i)
    testimony_i=[]
    for j in range(A_i):
        x,y= map(int,input().split())

        testimony_i.append([x,y])
    
    test.append(testimony_i)

print(A)
print(test)


total=0

for i in range(2**N):

    member = format(i,'0{}b'.format(N))

    print(member)
    flg = 0

    for j in range(N):
        if member[j]== '1':

            syogen = test[j]

            for s in syogen:
                if member[s[0]-1]==str(s[1]):
                    continue
                else:
                    flg+=1

    if flg ==0:
        total = max(total , member.count('1')) 

print(total)


    

    
#     for j in range(N):

#         if (i>>j) & 1:

#             A_j = A[j]
            
#             for k in range(A_j):
#                 x,y =test[j][k][0],test[j][k][1]

#                 x-=1


#                 else:

#         else:
#             A_j=A[j]

#             for k in range(A_j):
#                 x,y =test[j][k][0],test[j][k][1]

#                 x-=1


#                 else:

            


# print(total)




N=int(input())

A=[]
test = []
for i in range(N):
    A_i= int(input())
    A.append(A_i)
    testimony_i=[]
    for j in range(A_i):
        x,y= map(int,input().split())

        testimony_i.append([x,y])
    
    test.append(testimony_i)
    
total=0
for i in range(2**N):

    member = format(i,'0{}b'.format(N))

    flg = 0

    for j in range(N):
        if member[j]== '1':

            syogen = test[j]

            for s in syogen:
                if member[s[0]-1]==str(s[1]):
                    continue
                else:
                    flg+=1

    if flg ==0:
        total = max(total , member.count('1')) 

print(total)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted