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())
x = [0]*(n+1)
y = [0]*(n+1)
for i in range(n):
  a = int(input())
  x[i+1] = [0]*a
  y[i+1] = [0]*a
  for j in range(a):
    x[i+1][j], y[i+1][j] = map(int, input().split())

t = []
l = []
ans = 0
flag = 0
f = 1
for i in range(n):
  t.append(i+1)
  t_ = [i+1]
  flag = 1
  while(flag == 1):
    flag = 0
    t__ = [z for z in t_]
    t_ = []
    for m in t__:
      for j, k in zip(x[m],y[m]):
        if k == 0:
          if j in t or j in t_:
            f = 0
            t = []
            l = []
            t_ = []
            break
          l.append(j)
        if k == 1:
          if j in l:
            f = 0
            t = []
            l = []
            t_ = []
            break
          if j not in t and j not in t_:
            t_.append(j)
            flag = 1
      if f == 0:
        flag = 0
        t_ = []
        break
    t.extend(t_)
  if f != 0:
    ans = max(ans,len(t))
  remain = list(set(range(1,n+1))-set(t)-set(l))
  if len(remain)>0:
    T = [z for z in t]
    L = [z for z in l]
    for u in remain:
      t.append(u)
      t_ = [u]
      flag = 1
      while(flag == 1):
        flag = 0
        t__ = [z for z in t_]
        t_ = []
        for m in t__:
          for j, k in zip(x[m],y[m]):
            if k == 0:
              if j in t or j in t_:
                f = 0
                t = []
                l = []
                t_ = []
                break
              l.append(j)
            if k == 1:
              if j in l:
                f = 0
                t = []
                l = []
                t_ = []
                break
              if j not in t and j not in t_:
                t_.append(j)
                flag = 1
          if f == 0:
            flag = 0
            t_ = []
            t = [z for z in T]
            l = [z for z in L]
            break
        t.extend(t_) 
      if f != 0:
        ans = max(ans,len(t))
        T = [z for z in t]
    	L = [z for z in l]
print(ans)

n = int(input())
x = [0]*(n+1)
y = [0]*(n+1)
for i in range(n):
  a = int(input())
  x[i+1] = [0]*a
  y[i+1] = [0]*a
  for j in range(a):
    x[i+1][j], y[i+1][j] = map(int, input().split())

t = []
l = []
ans = 0
flag = 0
f = 1
for i in range(n):
  if i+1 not in t and i+1 not in l:
    t_ = [i+1]
  flag = 1
  while(flag == 1):
    flag = 0
    t__ = [z for z in t_]
    t_ = []
    for m in t__:
      for j, k in zip(x[m],y[m]):
        if k == 0:
          if j in t or j in t_:
            f = 0
            t = []
            l = []
            t_ = []
            break
          l.append(j)
        if k == 1:
          if j in l:
            f = 0
            t = []
            l = []
            t_ = []
            break
          if j not in t and j not in t_:
            t_.append(j)
            flag = 1
      if f == 0:
        flag = 0
        t_ = []
        break
    t.append(i+1)
    t.extend(t_)
  if f != 0:
    ans = max(ans,len(t))
print(ans)

n = int(input())
x = [0]*(n)
y = [0]*(n)
for i in range(n):
  a = int(input())
  x[i] = [0]*a
  y[i] = [0]*a
  for j in range(a):
    x[i][j], y[i][j] = map(int, input().split())

A = 0
for i in range(2**n):
  flag = 0
  ans = 0
  num = list(format(i, '0{}b'.format(n)))
  for j, k in enumerate(num):
    if k == "1":
      ans += 1
      for l, m in zip(x[j], y[j]):
        if num[l-1] != "{}".format(m):
          flag = 1
          break
    if flag == 1:
      break
  if flag == 0:
  	A = max(A,ans)
print(A)

Verdicts: Runtime Error

Wrong Answer

Accepted