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())
Harray = []
for i in range(N):
    Aarray = []
    A = int(input())
    for j in range(A):
        xy = list(map(int,input().split()))
        Aarray.append(xy)
    Harray.append(Aarray)

carray = []

for Ai in Harray:
    honest = [Ai]
    for ans in Ai:
        que = []
        if ans[1] == 1:
            honest.append(Harray[ans[0]-1])
            que.append(ans[0]-1)
        while len(que) > 0:
            d = que[0]

            que.pop(0)
            
            e = 0
            for h in honest:
                for h2 in h:
                    if h2[1] == 1:
                        h3 = [h2[0], 0]
                    else:
                        h3 = [h2[0], 1]
                    if h3 in Harray[d]:
                        e = 1
                    if [Harray.index(h),0] in Harray[d]:
                        e = 1
            
            if e == 0:
                for ans2 in Harray[d]:
                    if (ans2[1] == 1) and (ans2 not in honest):
                        que.append(ans2[0]-1)
            else:
                honest = []
                break
                    
    carray.append(len(honest))

print(max(carray))


N = int(input())
Harray = []
for i in range(N):
    Aarray = []
    A = int(input())
    for j in range(A):
        xy = list(map(int,input().split()))
        Aarray.append(xy)
    Harray.append(Aarray)

carray = []

for Ai in Harray:
    honest = [Harray.index(Ai)]
    honestcont = [Ai]
    for ans in Ai:
        que = []
        if ans[1] == 1:
            honest.append(ans[0]-1)
            honestcon.append(Harray[ans[0]-1])
            que.append(ans[0]-1)
        while len(que) > 0:
            d = que[0]

            que.pop(0)
            
            e = 0
            for h in honestcon:
                if h[1] == 1:
                    h2 = [h[0], 0]
                else:
                    h2 = [h[0], 1]
                if h2 in Harray[d]:
                    e = 1
            
            for h4 in honest:
                if [h4,0] in Harray[d]:
                    e = 1
            
            if e == 0:
                for ans2 in Harray[d]:
                    if (ans2[1] == 1) and (ans2[0] not in honest):
                        que.append(ans2[0]-1)
            else:
                honest = []
                break
                    
    carray.append(len(honest))

print(max(carray))


N = int(input())
Harray = []
for i in range(N):
    Aarray = []
    A = int(input())
    for j in range(A):
        xy = list(map(int,input().split()))
        Aarray.append(xy)
    Harray.append(Aarray)

carray = []

for Ai in Harray:
    honest = [Ai]
    c = 1
    for ans in Ai:
        que = []
        if ans[1] == 1:
            c += 1
            honest.append(Harray[ans[0]-1])
            que.append(ans[0]-1)
        while len(que) > 0:
            d = que[0]

            que.pop(0)
            
            e = 0
            for h in honest:
                for h2 in h:
                    if h2[1] == 1:
                        h3 = [h2[0], 0]
                    else:
                        h3 = [h2[0], 1]
                    if h3 in Harray[d]:
                        e = 1
            
            if e == 0:
                for ans2 in Harray[d]:
                    if (ans2[1] == 1) and (ans2[0] not in honest):
                        c += 1
                        que.append(ans2[0]-1)
            else:
                honest = []
                break
                    
    carray.append(len(honest))

print(max(carray))


N= int(input())
Harray = []
for i in range(N):
    Aarray = []
    A = int(input())
    for j in range(A):
        xy = list(map(int,input().split()))
        Aarray.append(xy)
    Harray.append(Aarray)


count = []
for i in range(2**N):
    honest = [0 for i in range(N)]
    c = 0
    for j in range(N):
        if (i >> j) & 1 == 1:
            honest[j] = 1
    for k in range(N):
        if honest[k] == 1:
            ar = Harray[k]
            for l in ar:
                if honest[l[0]-1] != l[1]:
                    c = 1
    if c == 0:
        count.append(honest.count(1))
print(max(count))

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted