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())
a=[]
for i in range(n):
    n2=int(input())
    a2=[[int(i) for i in input().split()] for i in range(n2)]
    a.append(a2)
print(a)
maxi=0
for i in range(2**n):
    if i!=5:
        continue
    tf=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tf[j]=True
    judge=[None]*n
    flag=True
    for x,a1 in enumerate(a):
        if flag==False:
            break
        if tf[x]==True:
            torf=True
        else:
            torf=False
        for a2 in a1:
            if torf==True:
                if judge[x]==True or judge[x]==None:
                    if judge[a2[0]-1]==None:
                        if a2[1]==1 and (tf[x]==True or tf[a2[0]-1]==None):
                            judge[a2[0]-1]=True
                        elif a2[1]==0 and (tf[x]==False or tf[a2[0]-1]==None):
                            judge[a2[0]-1]=False
                    elif judge[a2[0]-1]==True:
                        if a2[1]==1:
                            pass
                        else:
                            flag=False
                            break
                    else:
                        if a2[1]==0:
                            pass
                        else:
                            flag=False
                            break
                else:
                    flag=False
                    break
            else:
                if judge[x]==False or judge[x]==None:    
                    if judge[a2[0]-1]==None:
                        pass
                    elif judge[a2[0]-1]==True:
                        if a2[1]==0:
                            pass
                        else:
                            pass
                    else:
                        if a2[1]==1:
                            pass
                        else:
                            pass
                else:
                    flag=False
                    break
    if flag==True:
        maxi=max(maxi,judge.count(True))
        print(tf,judge,judge.count(True))
print(maxi)

n=int(input())
a=[]
for i in range(n):
    n2=int(input())
    a2=[[int(i) for i in input().split()] for i in range(n2)]
    a.append(a2)
maxi=0
for i in range(2**n):
    if i!=5:
        continue
    tf=[False]*n
    for j in range(n):
        if (i>>j)&1:
            tf[j]=True
    judge=[None]*n
    flag=True
    for x,a1 in enumerate(a):
        if flag==False:
            break
        if tf[x]==True:
            torf=True
        else:
            torf=False
        for a2 in a1:
            if torf==True:
                if judge[x]==True or judge[x]==None:
                    if judge[a2[0]-1]==None:
                        if a2[1]==1 and (tf[x]==True or tf[a2[0]-1]==None):
                            judge[a2[0]-1]=True
                        elif a2[1]==0 and (tf[x]==False or tf[a2[0]-1]==None):
                            judge[a2[0]-1]=False
                    elif judge[a2[0]-1]==True:
                        if a2[1]==1:
                            pass
                        else:
                            flag=False
                            break
                    else:
                        if a2[1]==0:
                            pass
                        else:
                            flag=False
                            break
                else:
                    flag=False
                    break
            else:
                if judge[x]==False or judge[x]==None:    
                    if judge[a2[0]-1]==None:
                        pass
                    elif judge[a2[0]-1]==True:
                        if a2[1]==0:
                            pass
                        else:
                            pass
                    else:
                        if a2[1]==1:
                            pass
                        else:
                            pass
                else:
                    flag=False
                    break
    if flag==True:
        maxi=max(maxi,judge.count(True))
print(maxi)

n=int(input())
a=[]
for i in range(n):
    x=int(input())
    b=[[int(i) for i in input().split()] for i in range(x)]
    a.append(b)

ans=0

for i in range(2**n):
    status=[True]*n
    for j in range(n):
        if ((i>>j)&1):
            status[j]=False
    
    judge=[None]*n
    contradiction=False
    
    for x,person in enumerate(a):
        if status[x]==False:
            continue
        for testimony in person:
            if testimony[1]==1: 
                if judge[testimony[0]-1]!=False and status[testimony[0]-1]==True:
                    judge[testimony[0]-1]=True
                else:
                    contradiction=True
            else:
                if judge[testimony[0]-1]!=True and status[testimony[0]-1]==False:
                    judge[testimony[0]-1]=False
                else:
                    contradiction=True

    if contradiction==False:
        ans=max(ans,status.count(True))
print(ans)
            

Verdicts: Wrong Answer

Wrong Answer

Accepted