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

As = [[] for _ in range(N)]

for i in range(N):
    n = int(input())
    for j in range(n):
        A = [int(k) for k in input().split()]
        person, state = A[0], A[1]
        As[i].append([person-1, state])


honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):  
        if (i>>j) & 1 == 1:   
            for x, y in As[j]:
                if (j>>x) & 1 != y:  
                    flag = 1
                    break
    if flag == 0:
        
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

N = int(input())

As = [[] for _ in range(N)]

for i in range(N):
    n = int(input())
    for j in range(n):
        person, state = map(int, input().split())
        As[i].append([person-1, state])


honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):  
        if (i>>j) & 1 == 1:   
            for x, y in As[j]:
                if (j>>x) & 1 != y:  
                    flag = 1
                    break
    if flag == 0:
        
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

N = int(input())

As = [[] for _ in range(N)]

for i in range(N):
  n = int(input())
  for j in range(n):
    person, state = [int(k) for k in input().split()]
    As[i].append([person-1, state])
        
honest = 0
for i in range(2**N):
  flag = 0
  for j in range(N):
    if (i>>j) & 1 == 1:
      for x, y in As[j]:
        if (j>>x) & 1 != y:
          flag = 1
          break
  if flag == 0:
    honest = max(honest, bin(i)[2:].count('1'))

print(honest)

N = int(input())

As = [[] for _ in range(N)]

for i in range(N):
    n = int(input())
    for j in range(n):
        A = [int(k) for k in input().split()]
        person, state = A[0], A[1]
        As[i].append([person-1, state])


honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):  
        if (i>>j) & 1 == 1:   
            for x, y in As[j]:
                if (j>>x) & 1 != y:  
                    flag = 1
                    break
    if flag == 0:
        
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

N = int(input())

As = [[] for _ in range(N)]

for i in range(N):
  n = int(input())
  for j in range(n):
    person, state = [int(k) for k in input().split()]
    As[i].append([person-1, state])
        
honest = 0
for i in range(2**N):
  flag = 0
  for j in range(N):
    if (i>>j) & 1:
      for x, y in As[j]:
        if (j>>x) & 1 != y:
          flag = 1
          break
  if flag == 0:
    honest = max(honest, bin(i)[2:].count('1'))

print(honest)

N = int(input())

As = [[] for _ in range(N)]

for i in range(N):
    n = int(input())
    for j in range(n):
        person, state = [int(k) for k in input().split()]
        As[i].append([person-1, state])

honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):  
        if (i>>j) & 1 == 1:   
            for x, y in As[j]:
                if (j>>x) & 1 != y:  
                    flag = 1
                    break
    if flag == 0:
        
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

N = int(input())

As = [[] for _ in range(N)]

for i in range(N):
  n = int(input())
  for j in range(n):
    person, state = [int(k) for k in input().split()]
    As[i].append([person-1, state])
    
print(As)
    
honest = 0
for i in range(2**N):
  flag = 0
  for j in range(N):
    if (i>>j) & 1:
      for x, y in As[j]:
        if (j>>x) & 1 != y:
          flag = 1
          break
  if flag == 0:
    honest = max(honest, bin(i)[2:].count('1'))

print(honest)

N = int(input())

As = [[] for _ in range(N)]

for i in range(N):
    n = int(input())
    for j in range(n):
        person, state = map(int, input().split())
        As[i].append([person-1, state])

honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):  
        if (i>>j) & 1 == 1:   
            for x, y in As[j]:
                if (i>>x) & 1 != y:  
                    flag = 1
                    break
    if flag == 0:
        
        honest = max(honest, bin(i)[2:].count('1'))

print(honest)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted