Problem:


Score : 300 points

Problem Statement

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?

Constraints

All values in input are integers.

1 \leq N \leq 15

0 \leq A_i \leq N - 1

1 \leq x_{ij} \leq N

x_{ij} \neq i

x_{ij_1} \neq x_{ij_2} (j_1 \neq j_2)

y_{ij} = 0, 1

Input

Input is given from Standard Input in the following format:

N
A_1
x_{11} y_{11}
x_{12} y_{12}
:
x_{1A_1} y_{1A_1}
A_2
x_{21} y_{21}
x_{22} y_{22}
:
x_{2A_2} y_{2A_2}
:
A_N
x_{N1} y_{N1}
x_{N2} y_{N2}
:
x_{NA_N} y_{NA_N}

Output

Print the maximum possible number of honest persons among the N people.

Sample Input 1

3
1
2 1
1
1 1
1
2 0

Sample Output 1

2

If Person 1 and Person 2 are honest and Person 3 is unkind, we have two honest persons without inconsistencies, which is the maximum possible number of honest persons.

Sample Input 2

3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0

Sample Output 2

0

Assuming that one or more of them are honest immediately leads to a contradiction.

Sample Input 3

2
1
2 0
1
1 0

Sample Output 3

1



Sample input:
3
1
2 1
1
1 1
1
2 0


Sample output:
2

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
	sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if y == 2 and honest[x] != 2:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
        sayArray = sayTable[i]
		for x, y in sayArray:
			if y != honest[x] != y:
				return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
			return count(honest)
		else:
			return 0

	count = 0
	h = honest[i]
    sayArray = sayTable[i]
	if (h == 0 or h == 2) and checkHonest(sayArray, honest):
		copyHonest = honest[:]
		setHonest(sayArray, copyHonest)
		copyHonest[i] = 2
		c = search(sayTable, copyHonest, i + 1)
		if count < c:
			count = c

	honest[i] = 1
	c = search(sayTable, honest, i+1)
	if count < c:
		count = c
	return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
	sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if y == 2 and honest[x] != 2:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		for x, y in sayArray:
			if honest[x] != y:
				return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
			return count(honest)
		else:
			return 0

	count = 0
	h = honest[i]
    sayArray = sayTable[i]
	if (h == 0 or h == 2) and checkHonest(sayArray, honest):
		copyHonest = honest[:]
		setHonest(sayArray, copyHonest)
		copyHonest[i] = 2
		c = search(sayTable, copyHonest, i + 1)
		if count < c:
			count = c

	honest[i] = 1
	c = search(sayTable, honest, i+1)
	if count < c:
		count = c
	return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
	sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if y == 2 and honest[x] != 2:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		for x, y in sayArray:
		if honest[x] != y:
			return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
			return count(honest)
		else:
			return 0

	count = 0
	h = honest[i]
    sayArray = sayTable[i]
	if (h == 0 or h == 2) and checkHonest(sayArray, honest):
		copyHonest = honest[:]
		setHonest(sayArray, copyHonest)
		copyHonest[i] = 2
		c = search(sayTable, copyHonest, i + 1)
		if count < c:
			count = c

	honest[i] = 1
	c = search(sayTable, honest, i+1)
	if count < c:
		count = c
	return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
	sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if y == 2 and honest[x] != 2:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		for x, y in sayArray:
		if honest[x] != y:
			return False
	return True

def setHonest(honest, sayArray):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
			return count(honest)
		else:
			return 0

	count = 0
	h = honest[i]
	if (h == 0 or h == 2) and checkHonest(sayTable, honest):
		copyHonest = honest[:]
		setHonest(copyHonest, sayTable[i])
		copyHonest[i] = 2
		c = search(sayTable, copyHonest, i + 1)
		if count < c:
			count = c

	honest[i] = 1
	c = search(sayTable, honest, i+1)
		if count < c:
			count = c
	return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
	sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if y == 2 and honest[x] != 2:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		for x, y in sayArray:
		if honest[x] != y:
			return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
			return count(honest)
		else:
			return 0

	count = 0
	h = honest[i]
	if (h == 0 or h == 2) and checkHonest(sayTable, honest):
		copyHonest = honest[:]
		setHonest(copyHonest, sayTable[i])
		copyHonest[i] = 2
		c = search(sayTable, copyHonest, i + 1)
		if count < c:
			count = c

	honest[i] = 1
	c = search(sayTable, honest, i+1)
		if count < c:
			count = c
	return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
prf = [[] for _ in range(n)]
for i in range(n):
    a.append(int(input()))
    for _ in range(a[-1]):
        x, y = map(int, input().split())
        a[i].append((x-1, y))

res = 0
for i in range(1<<n):
    flg = True
    cnt = 0
    for j in range(n):
        if ( i >>j & 1 ) == 1:
            cnt += 1
    for j in range(n):
        if ( i >>j & 1 ) == 1:
            for x,y in a[j]:
                if y == 0 and ( i >> x & 1 ) == 1:
                    flg = False
                if y == 1 and ( i << x & 1 ) == 0:
                    flg = False
    if flg:
        ans = max(ans, cnt)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if y == 2 and honest[x] != 2:
return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		for x, y in sayArray:
		if honest[x] != y:
return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
return count(honest)
else:
	return 0

count = 0
h = honest[i]
if (h == 0 or h == 2) and checkHonest(sayTable, honest):
copyHonest = honest[:]
setHonest(honest, sayTable[i])
copyHonest[i] = 2
c = search(sayTable, copyHonest, i + 1)
if count < c:
	count = c

honest[i] = 1
c = search(sayTable, honest, i+1)
	if count < c:
		count = c
return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n=int(input())
X=[]
Y=[]
A=[]
for i in range(n):
  A[i]=int(input())
  x=[]
  y=[]
  for j in range(A[i]):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
if c<l.count(1):
  c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
 main():
    N = int(input())
    person_list = [i for i in range(1, N+1)]
    
    ans_per_dic = {}
    ans_pattern_dic = {}
    honest_pattern = combinations(N, person_list)
    for i in range(1, N+1):
        ans_per_dic[i] = 0
        A = int(input())
        ans_list = []
        for a in range(A):
            l = input().rstrip().split(" ")
            l = [int(x) for x in l]
            ans_list.append(l)
        ans_pattern_dic[i] = ans_list
    
    cnt = 0
    
    for pattern in honest_pattern:
        temp_dic = ans_per_dic.copy()
        for p in pattern:
            temp_dic[p] = 1
        flag = True
        for person, answer in ans_pattern_dic.items():
            if judge(temp_dic, person, answer) == False:
                flag = False
                break
        if (flag == False):
            continue
        if cnt < len(pattern):
            cnt = len(pattern)
    print(cnt)
            
def judge(temp_dic, person, answer):
    if temp_dic[person] == 1:
        for ans in answer:
            if temp_dic[ans[0]] != ans[1]:
                return False
    else:
        return False
    return True
    
def combinations(n, guest_list):
    all_comb_list = []
    for i in range(1, 2**n):
        num = i
        c_list = []
        for j in range(n):
            if num % 2 == 1:
                c_list = [guest_list[n - 1 - j]] + c_list
            num = num // 2
        all_comb_list.append(c_list)
    return all_comb_list
    
 
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
X=[]
Y=[]
for i in range(n):
  A=int(input())
  x=[]
  y=[]
  for j in range(A[i]):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
if c<l.count(1):
  c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
for i in range(n):
  A=int(input())
  x=[]
  y=[]
  for j in range(A[i]):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
if c<l.count(1):
  c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
	sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if say != 2:
			continue
		if say != honest[x]:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		if not checkHonest(sayTable[i]):
			return False
	return True

def setHonest(sayArray, honest):
	for x, y in sayArray:
		honest[x] = y

def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
			return count(honest)
		else:
			return 0

	count = 0
	h = honest[i]
	if (h == 0 or h == 2) and checkHonest(sayTable, honest):
  		copyHonest = honest[:]
        setHonest(honest, sayTable[i])
		copyHonest[i] = 2
		c = search(sayTable, copyHonest, i + 1)
		if count < c:
			count = c

	honest[i] = 1
	c = search(sayTable, honest, i+1)
	if count < c:
		count = c
	return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  A=int(input())
  x=[]
  y=[]
  for j in range(A[i]):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
if c<l.count(1):
  c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(A[i]):
    x,y=[int(s) for s in input().split()]
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
if c<l.count(1):
  c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())
xy = [0 for _ in range(n)]
for i in range(n):
    ai = int(input())
    xy[i] = [list(map(int , input().split())) for _ in range(ai)]

#print(xy)
#print(xy[0])
#print(xy[0][0])
ans = 0
for i in itertools.product([0, 1], repeat=n):
    ok = True
    cnt = sum(i)
    for j in range(n):
        xyj = xy[j]
        for xyk in xyj:
            if xyk[1] == 0:
                if i[xyk[0]] == 1:
                    ok = False
            elif xyk[1] == 1:
                if i[xyk[0]] == 0:
                    ok = False
    if ok:
        ans = max(ans, cnt)

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

sayTable = []
for i in range(n):
	a = int(input())
	
	sayArray = []
	for j in range(a):
		x, y = [int(v) for v in input().split()]
		sayArray.append((x-1, y+1))
sayTable.append(sayArray)

def count(honest):
	count = 0
	for v in honest:
		if v == 2:
			count += 1
	return count

def checkHonest(sayArray, honest):
	for x, y in sayArray:
		if say != 2:
			continue
		if say != honest[x]:
			return False
	return True

def checkHonestAll(sayTable, honest):
	for i in range(n):
		h = honest[i]
		if h != 2:
			continue
		if not checkHonest(sayTable[i]):
			return False
	return True









def search(sayTable, honest, i):
	if i >= n;
		if checkHonestAll(sayTable, honest):
return count(honest)
else:
	return 0

count = 0
h = honest[i]
if (h == 0 or h == 2) and checkHonest(sayTable, honest):
copyHonest = honest[:]
copyHonest[i] = 2
c = search(sayTable, copyHonest, i + 1)
if count < c:
	count = c

honest[i] = 1
c = search(sayTable, honest, i+1)
	if count < c:
		count = c
return count

print(search(sayTable, [0] * n, 0));

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(A[i]):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
if c<l.count(1):
  c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(A[0]):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
if c<l.count(1):
  c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(A[0]):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
  if c<l.count(1):
    c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(A[0]):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
  if c<l.count(1):
    c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(a):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
  if c<l.count(1):
    c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
#n=int(input())
#A=[]
#X=[]
#Y=[]
#for i in range(n):
 # a=int(input())
 # A.append(a)
 # x=[]
 # y=[]
  #for j in range(a):
   # x1,y1=[int(s) for s in input().split()]
   # x.append(x1)
    #y.append(y1)
  #X.append(x)
  #Y.append(y)
  
#c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
#print(c)

Submission status: Runtime Error

Solution code:
#n=int(input())
#A=[]
#X=[]
#Y=[]
#for i in range(n):
 # a=int(input())
 # A.append(a)
 # x=[]
 # y=[]
  #for j in range(a):
   # x1,y1=[int(s) for s in input().split()]
   # x.append(x1)
    #y.append(y1)
  #X.append(x)
  #Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(a):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
#print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  x=[]
  y=[]
  for j in range(a):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
N = int(input())
Nloop = N + 1
A = [[0] * Nloop for _ in range(Nloop)]

for i in range(1, Nloop):
    Acount = int(input())
    for _ in range(Acount):
        x, y = map(int,input().split())
        A[i, x] = 1 if y == 1 else -1

honest_loop = 2 ** N
is_honest = [False] * Nloop

ans = 0

for i in range(1, honest_loop):
    for l in range(1, Nloop):
        is_honest[l] = (i >> (l - 1) & 1 == 1)

    honest_check = True
    for l in range(1, Nloop):
        # lの人が正直者のとき
        if is_honest[l]:
            # lの人から見てjの人は正直者か？
            for j in range(1, Nloop):
                if A[l, j] == 1:
                    if not is_honest[j]:
                        honest_check = False
                elif A[l, j] == -1:
                    if is_honest[j]:
                        honest_check = False
                if not honest_check:
                    break
        if not honest_check:
            break

    if honest_check:
        ans = max(sum(is_honest), ans)

print(ans)

Submission status: Runtime Error

Solution code:
#n=int(input())
#A=[]
#X=[]
#Y=[]
#for i in range(n):
 # a=int(input())
  #A.append(a)
  #x=[]
  #y=[]
  #for j in range(a):
    #x1,y1=[int(s) for s in input().split()]
    #x.append(x1)
    #y.append(y1)
  #X.append(x)
  #Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
#A=[]
#X=[]
#Y=[]
#for i in range(n):
 # a=int(input())
  #A.append(a)
  #x=[]
  #y=[]
  #for j in range(a):
    #x1,y1=[int(s) for s in input().split()]
    #x.append(x1)
    #y.append(y1)
  #X.append(x)
  #Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
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)
# table[i][x] 人iが人xを正直者;1,真偽不明:0,未言及:-1

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????

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
#for i in range(n):
 # a=int(input())
  #A.append(a)
  x=[]
  y=[]
  #for j in range(a):
    #x1,y1=[int(s) for s in input().split()]
    #x.append(x1)
    #y.append(y1)
  #X.append(x)
  #Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
for i in range(n):
  a=int(input())
  #A.append(a)
  x=[]
  y=[]
  for j in range(a):
    x1,y1=[int(s) for s in input().split()]
    #x.append(x1)
    #y.append(y1)
  #X.append(x)
  #Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
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)
# table[i][x] 人iが人xを正直者;1,真偽不明:0,未言及:-1
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????

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
A = [0]*N
xy = []
for i in range(N):
    A[i] = int(input())
    z = [list(map(int, input().split())) for _ in range(A[i])]
    xy.append(z)

ans = np.ones(N).astype(int)
arr = np.array(xy)
x = arr[:,:,0].flatten()
y = arr[:,:,1].flatten()
z = np.vstack((x, y))
for i in range(N):
    for j in range(A[i]):
        pass
c = []*N
for i in range(N):
    for j in range(1,N+1):
        if z[0][i] == j:
            ans[i] *= z[1][i]
            #c[j-1].append(z[1][i])
        
        
print(sum(ans))

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
data_dict = {}
data_re_dict = {}
for i in range(1, n + 1):
    temp = int(input())
    temp_list = []
    for j in range(0, temp):
        x, y = map(int, input().split())
        temp_list.append(x)
        temp_list.append(y)
        if x in data_re_dict:
            
    data_dict[i] = temp_list
max_o_man = 0
for i in range(1, n + 1):
    check_dict = {}
    check_list = [-100] * n
    check_list[i-1] = 1
    check_dict[i] = 1
    count = 1
    for j in range(0, len(data_dict[i]), 2):
        check_dict[data_dict[i][j]] = data_dict[i][j+1]
        check_list[data_dict[i][j]-1] = 0
        if data_dict[i][j+1] == 1:
            count += 1
    flag = 1
    for k in range(0, n - 1):
        x = -1
        if 0 not in check_list:
            x = check_list.index(-100)
            check_dict[x + 1] = 1
            count += 1
        else:
            x = check_list.index(0)
        check_list[x] = 1
        for j in range(0, len(data_dict[x + 1]), 2):
            if data_dict[x + 1][j] in check_dict:
                if check_dict[x + 1] == 1:
                    if check_dict[data_dict[x + 1][j]] != data_dict[x + 1][j+1]:
                        flag = 0
                        break
                elif check_dict[x + 1] == 0:
                    if check_dict[data_dict[x + 1][j]] == data_dict[x + 1][j+1]:
                        flag = 0
                        break
            else:
                check_dict[data_dict[x + 1][j]] = data_dict[x + 1][j+1]
                check_list[data_dict[x + 1][j]-1] = 0
                if data_dict[x + 1][j+1] == 1:
                    count += 1
        if flag == 0:
            break
    if flag == 1:
        if max_o_man < count:
            max_o_man = count
        if max_o_man == n:
            break
print(max_o_man)

Submission status: Runtime Error

Solution code:

Copy
Copy
n = int(input())
comments = {}
for i in range(n):
  a = int(input())
  comments[i] = []
  for _ in range(a):
    x, y = [int(x) for x in input().split()]
    comments[i].append([x-1, y==1])
 
ans = 0
for i in range(2**n):
  results = [None] * n
  for j in range(n):
    candidate = ((i >> j) & 1) == 1
    if results[j] is None:
      results[j] = candidate
    elif results[j] != candidate:
      break
    if candidate == False:
      continue
    elif candidate == True:
      failed = False
      for comment in comments[j]:
        if results[comment[0]] is None:
          results[comment[0]] = comment[1]
        if results[comment[0]] != comment[1]:
          failed = True
          break
      if failed:
        break
  else:
    cnt = len([r for r in results if r is True])
    if cnt > ans:
      ans = cnt
 
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
x=[]
y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  for j in range(a):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
#for i in range(n):
 # l=[1]*n
  #for j in range(i, n-i):
   # if l[j]==0:continue
    #for k in range(A[j]):
    　#　l[X[j][k]] *= Y[j][k]
  #if c<l.count(1):
   # c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
x=[]
y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  for j in range(a):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n-i):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
  if c<l.count(1):
    c=l.count(1) 
  
        
  
print(c)

Submission status: Runtime Error

Solution code:
n=int(input())
A=[]
X=[]
Y=[]
x=[]
y=[]
for i in range(n):
  a=int(input())
  A.append(a)
  for j in range(a):
    x1,y1=[int(s) for s in input().split()]
    x.append(x1)
    y.append(y1)
  X.append(x)
  Y.append(y)
  
c=0
for i in range(n):
  l=[1]*n
  for j in range(i, n):
    if l[j]==0:continue
    for k in range(A[j]):
    　　l[X[j][k]] *= Y[j][k]
  if c<l.count(1):
    c=l.count(1) 
  
        
  
print(c)