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):
import math

def resolve():
    N = int(input())
    A_list = []
    xy_list = []
    for i in range(N):
        A_list.append(int(input()))
        tmp_list = []
        for j in range(A_list[i]):
            tmp_list.append(tuple(int(i) for i in input().split()))
        xy_list.append(tmp_list)

    answer = 0

    for bit in range(1<<N):
        pattern = []
        for j in range(N):
            if (bit & (1<<j)):
                pattern.append(j)

        for j in range(N):
            if check(j, pattern, xy_list) == 0:
                break
            else:
                answer = max(answer, len(pattern))

    print(answer)

# j : 1 <= j < N-1
# pattern : 
# xy_list : 
def check(j, pattern, xy_list):
    if j in pattern:
        for x, y in xy_list[j]:
            if not y and (x-1 in pattern):
                return 0
            if y and (x-1 not in pattern):
                return 0
        return 1
            

if __name__ == "__main__":
    resolve()

import math

def resolve():
    N = int(input())
    A_list = []
    xy_list = []
    for i in range(N):
        A_list.append(int(input()))
        tmp_list = []
        for j in range(A_list[i]):
            tmp_list.append(tuple(int(i) for i in input().split()))
        xy_list.append(tmp_list)

    print(xy_list)
    answer = 0

    for bit in range(1<<N):
        pattern = []
        for j in range(N):
            if (bit & (1<<j)):
                pattern.append(j)
            
        print(pattern)

        for j in range(N):
            if check(j, pattern, xy_list) == 0:
                break
        else:
            answer = max(answer, len(pattern))

    print(answer)


# pattern : pattern
# xy_list : 
# return - 0 : 
#        - 1 : 
def check(j, pattern, xy_list):
    if j in pattern:
        for x, y in xy_list[j]:
            if not y and (x-1 in pattern):
                return 0
            if y and (x-1 not in pattern):
                return 0
        return 1
            

if __name__ == "__main__":
    resolve()

n=int(input())
a=[0]*n
xy=[]
for i in range(n):
    a[i]=int(input())
    hoge=[]*a[i]
    for j in range(a[i]):
        hoge.append(tuple(int(i) for i in input().split()))
    xy.append(hoge)
 
ans=0
def check(j,pattarn):
    if j in pattarn:
        for x,y in xy[j]:
            if not y and (x-1 in pattarn):
                return 0
            if y and (x-1 not in pattarn):
                return 0
        return 1
 
for bit in range(1<<n):
    pattarn = []
    for j in range(n):
        if (bit & (1<<j)):
            pattarn.append(j)
 
    for j in range(n):
        if check(j,pattarn)==0:
            break
    else:
        ans=max(ans,len(pattarn))
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted