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())
total = 0
tmp = 0
A = []
xy = []
l = []
for i in range(N):
  A.append(int(input())
  for j in range(A[i]):
    l.append(list(map(int,input().split())))
  xy.append(l)
  l.clear()
for i in range(2**N):
  flag = 1
  t = format(i, '0{}b'.format(N))
  for k in range(N):
    if t[k] == '1':
      tmp += 1
      for l in range(A[k]):
        if int(t[xy[k][l][0]-1]) != xy[k][l][1]:
          flag = 0
          break
      else:
        continue
      break
  if flag == 1 and total < tmp:
    total = tmp
  tmp = 0
print(total)
          


N = int(input())
total = 0
tmp = 0
A = []
xy = []
for i in range(N):
  A.append(int(input())
  t = [list(map(int,input().split())) for j in range(A[i])]
  xy.append(t)
for i in range(2**N):
  flag = 1
  i = format(i, '0{}b'.format(N))
  for k in range(N):
    if i[k] == '1':
      tmp += 1
      for l in range(A[k]):
        if int(i[xy[k][l][0]]) != xy[k][l][1]:
          flag = 0
          break
      else:
        continue
      break
  if flag == 1 and total < tmp:
    total = tmp
  tmp = 0
print(total)
          


N = int(input())
total = 0
tmp = 0
A = []
xy = []
for i in range(N):
  A.append(int(input())
  t = [list(map(int(input().split()))) for j in range(A[i])]
  xy.append(t)
for i in range(2**N):
  flag = 1
  i = format(i, '0{}b'.format(N))
  for k in range(N):
    if i[k] == '1':
      tmp += 1
      for l in range(A[k]):
        if int(i[xy[k][l][0]]) != xy[k][l][1]:
          flag = 0
          break
      else:
        continue
      break
  if flag == 1 and total < tmp:
    total = tmp
  tmp = 0
print(total)
          

N = int(input())
total = 0
tmp = 0
A = []
xy = []
for i in range(N):
  A.append(int(input())
  t = [list(map(int,input().split())) for j in range(A[i])]
  xy.append(t)
for i in range(2**N):
  flag = 1
  i = format(i, '0{}b'.format(N))
  for k in range(N):
    if i[k] == '1':
      tmp += 1
      for l in range(A[k]):
        if int(i[xy[k][l][0]]) != xy[k][l][1]:
          flag = 0
          break
      else:
        continue
      break
  if flag == 1 and total < tmp:
    total = tmp
  tmp = 0
print(total)
          


N = int(input())
total = 0
tmp = 0
A = []
xy = []
l = []
for i in range(N):
  A.append(int(input())
  for j in range(A[i]):
    l.append(list(map(int,input().split())))
  xy.append(l)
  l.clear()
for i in range(2**N):
  flag = 1
  i = format(i, '0{}b'.format(N))
  for k in range(N):
    if i[k] == '1':
      tmp += 1
      for l in range(A[k]):
        if int(i[xy[k][l][0]]) != xy[k][l][1]:
          flag = 0
          break
      else:
        continue
      break
  if flag == 1 and total < tmp:
    total = tmp
  tmp = 0
print(total)
          



N = int(input())
shougen = []
A_lis = []
for _ in range(N):
    A = int(input())
    A_lis.append(A)
    minishougen = []
    for j in range(A):
        xy = list(map(int, input().split()))
        minishougen.append(xy)
    shougen.append(minishougen)


bit_lis = []
for i in range(2 ** N):
    mini_bit_lis = []
    for j in range(N):
        mini_bit_lis.append(i % 2)
        i = i // 2
    bit_lis.append(mini_bit_lis)
    

ans = 0
for i in range(2 ** N):
    flag = 0
    for l in range(N):
        if bit_lis[i][l] == 1:
            for k in range(A_lis[l]): 
                if shougen[l][k][1] != bit_lis[i][shougen[l][k][0] - 1]:
                    flag = 1
                    break
        if flag == 1:
            break
    if flag == 0:
        tmp = sum(bit_lis[i])
        if tmp > ans :
            ans = tmp
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted