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

dic = dict()
cnt = 0

for i in range(N):
  Row=int(input())
  List=[list(map(int,input().split())) for i in range(Row)]
  cnt += 1
  dic[cnt]=List
  
shoujiki = []
uso = []
arr = []

for i in range(N):
  cnt = 0
  shoujiki.append(i+1)
  
  for j in range(N):
    a = dic[j+1]
    length = len(a)
    
    for k in range(length):
      if i > j:
        uso.append(j+1)
      elif j+1 in shoujiki:
        if dic[j+1][k][1] == 0:
          uso.append(dic[j+1][k][0])
        else:
          shoujiki.append(dic[j+1][k][0])
          
    set(shoujiki)
    set(uso)
    cnt = len(shoujiki)
    usolength = len(uso)
    for l in range(usolength):
      if uso[l] in shoujiki:
        cnt = cnt - 1
    arr.append(cnt)
  
  shoujiki = []
  uso = []
  
print(max(arr))


N = int(input())

dic = dict()
cnt = 0

for i in range(N):
  Row=int(input())
  List=[list(map(int,input().split())) for i in range(Row)]
  cnt += 1
  dic[cnt]=List
  
shoujiki = []
uso = []
arr = []

for i in range(N):
  cnt = 0
  shoujiki.append(i+1)
  
  for j in range(N):
    a = dic[j+1]
    length = len(a)
    
    for k in range(length):
      if i > j:
        uso.append(j+1)
      elif j+1 in shoujiki:
        if dic[j+1][k][1] == 0:
          uso.append(dic[j+1][k][0])
        else:
          shoujiki.append(dic[j+1][k][0])
          
    shoujiki = list(set(shoujiki))
    
    shoujikilength = len(shoujiki)
    for l in range(shoujikilength):
      length2 = len(dic[shoujiki[l]])
      for m in range(length2):
        if dic[shoujiki[l]][m][1] == 0:
          uso.append(dic[shoujiki[l]][m][0])
    
    cnt = len(shoujiki)
    
    uso = list(set(uso))
    usolength = len(uso)
    for l in range(usolength):
      if uso[l] in shoujiki:
        cnt = cnt - 1
    arr.append(cnt)
  
  shoujiki = []
  uso = []
  
print(arr) 
print(max(arr))


N = int(input())

dic = dict()
cnt = 0

for i in range(N):
  Row=int(input())
  List=[list(map(int,input().split())) for i in range(Row)]
  cnt += 1
  dic[cnt]=List
  
shoujiki = []
uso = []
arr = []

for i in range(N):
  cnt = 0
  shoujiki.append(i+1)
  
  for j in range(N):
    a = dic[j+1]
    length = len(a)
    
    for k in range(length):
      if i > j:
        uso.append(j+1)
      elif j+1 in shoujiki:
        if dic[j+1][k][1] == 0:
          uso.append(dic[j+1][k][0])
        else:
          shoujiki.append(dic[j+1][k][0])
          
    shoujiki = list(set(shoujiki))
    
    shoujikilength = len(shoujiki)
    for l in range(shoujikilength):
      length2 = len(dic[shoujiki[l]])
      for m in range(length2):
        if dic[shoujiki[l]][m][1] == 0:
          uso.append(dic[shoujiki[l]][m][0])
    
    for l in range(shoujikilength):
      length2 = len(dic[shoujiki[l]])
      for m in range(length2):
        if dic[shoujiki[l]][m][1] == 1:
          if dic[shoujiki[l]][m][0] in shoujiki:
            uso.append(dic[shoujiki[l]][m][0])
    for l in range(shoujikilength):
      length2 = len(dic[shoujiki[l]])
      for m in range(length2):
        if dic[shoujiki[l]][m][1] == 1:
          if dic[shoujiki[l]][m][0] in shoujiki:
            uso.append(dic[shoujiki[l]][m][0])
    cnt = len(shoujiki)
    
    uso = list(set(uso))
    usolength = len(uso)
    for l in range(usolength):
      if uso[l] in shoujiki:
        cnt = cnt - 1
    arr.append(cnt)
  
  
  shoujiki = []
  uso = []
  
print(max(arr))


n = int(input())
xy = []
for _ in range(n):
  a = int(input())
  xy.append([[int(i) for i in input().split()] for __ in range(a)])

ans = 0
for i in range(2**n):
  flag = True
  for j in range(n):
    if i >> j & 1:
      for x,y in xy[j]:
        if (i >> (x-1)&1) != y:
          flag = False
          break
  if flag:
    ans = max(ans, sum(map(int, bin(i)[2:])))
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted