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())
table = [[-1]*(N+1) for i in range(N+1)]
for i in range(1,N+1):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        table[i][x] = y
#print(table)


ans = 0
for i in range(2**N):

    
    # for j in range(N):
    
    #         hito[j] = 1
    # print(hito)

    flag = True
    cnt = 0
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            for k in range(N):
                if table[j+1][k+1] != -1:
                    #print(table[j+1][k+1])


                    if k == 0:
                    if table[j+1][k+1] ^ (i >> k):
                        # if j == 1 and k == 0:
                        #     print(i>>k)
                        #     print(table[j+1][k+1])
                        flag = False
                        #print(i,j,k)
    if flag:
        if cnt > ans:
            ans = cnt
print(ans)
# print(3 >> 0) # 3????
# print(1^3)



N = int(input())
table = [[-1]*(N) for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        table[i][x] = y
# print(table)

def my_shift(i,k):
    return int(str(bin(i))[-1]) if k == 0 else i>>k
ans = 0
for i in range(2**N):

    hito = [0]*N
    for j in range(N):
        if i >> j & 1:
            hito[j] = 1

    flag = True
    cnt = 0
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            for k in range(N):
                if table[j][k] != -1:
                    if table[j][k] != hito[k]:
                        flag = False
    if flag:
        if cnt > ans:
            ans = cnt
print(ans)
#print(3 >> 0) # 3????



N = int(input())
table = [[-1]*(N) for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        table[i][x] = y
# print(table)


ans = 0
for i in range(2**N):

    hito = [0]*N
    for j in range(N):
        if i >> j & 1:
            hito[j] = 1

    flag = True
    cnt = 0
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            for k in range(N):
                if table[j][k] != -1:
                    if table[j][k] != hito[k]:
                        flag = False
    if flag:
        if cnt > ans:
            ans = cnt
print(ans)
#print(3 >> 0) # 3????



N = int(input())
table = [[-1]*(N+1) for i in range(N+1)]
for i in range(1,N+1):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        table[i][x] = y
#print(table)


ans = 0
for i in range(2**N):

    
    # for j in range(N):
    
    #         hito[j] = 1
    # print(hito)

    flag = True
    cnt = 0
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            for k in range(N):
                if table[j+1][k+1] != -1:
                    #print(table[j+1][k+1])


                    if table[j+1][k+1] ^ (i >> k):
                        # if j == 1 and k == 0:
                        #     print(i>>k)
                        #     print(table[j+1][k+1])
                        flag = False
                        #print(i,j,k)
    if flag:
        if cnt > ans:
            ans = cnt
print(ans)
# print(3 >> 0) # 3????
# print(1^3)



N = int(input())
table = [[-1]*(N) for i in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x,y = map(int,input().split())
        table[i][x-1] = y
# print(table)


ans = 0
for i in range(2**N):

    hito = [0]*N
    for j in range(N):
        if i >> j & 1:
            hito[j] = 1

    flag = True
    cnt = 0
    for j in range(N):
        if i >> j & 1:
            cnt += 1
            for k in range(N):
                if table[j][k] != -1:
                    if table[j][k] != hito[k]:
                        flag = False
    if flag:
        if cnt > ans:
            ans = cnt
print(ans)
#print(3 >> 0) # 3????



Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted