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 = list()
good_person = list()
bad_person = list()
for i in range(1,n+1):
    t = int(input())
    A = list()
    for index in range(1,t+1):
        _input = input().split(" ")
        x = int(_input[0])
        y = int(_input[1])
        A.append((x, y))
    total.append(A)

for person in total:

    x = [x[0] for x in person]
    y = [y[1] for y in person]
    for index, a in enumerate(y):
        if a == 1:
            # good
            good_person.append(x[index])
        else:
            bad_person.append(x[index])
output = 0
# print(good_person)
# print(bad_person)
if sorted(good_person) == sorted(bad_person):
    output = 0
elif len(good_person) == 0:
    output = 1
elif len(good_person)< len(bad_person):
    output = 0
else:
    output = len(good_person) - len(bad_person)
print(output)

n = int(input())
total = list()
good = list()
bad = list()
for i in range(1,n+1):
    t = int(input())
    A = list()
    for index in range(1,t+1):
        _input = input().split(" ")
        x = int(_input[0])
        y = int(_input[1])
        A.append((x, y))
    total.append(A)

for person in total:
    good_person = list()
    bad_person = list()
    x = [x[0] for x in person]
    y = [y[1] for y in person]
    for index, a in enumerate(y):
        if a == 1:
            # good
            good_person.append(x[index])
        else:
            bad_person.append(x[index])
    
    #     print("check bad 1", bad_person)
    
    # print("check bad 2", bad_person)
    good.append(good_person)
    bad.append(bad_person)

print(len(good) - len(bad))

n = int(input())
total = list()
good = list()
for i in range(1,n+1):
    t = int(input())
    A = list()
    for index in range(1,t+1):
        _input = input().split(" ")
        x = int(_input[0])
        y = int(_input[1])
        A.append((x, y))
    total.append(A)

for person in total:
    good_person = list()
    x = [x[0] for x in person]
    y = [y[1] for y in person]
    for index, a in enumerate(y):
        if a == 1:
            # good
            good_person.append(x[index])
        else:
            try:
                good_person.remove(a)
            except(Exception):
                pass
        print("check 1",good_person)
    print("check 2",good_person)
    good.append(good_person)

print(len(good)-1)


n = int(input())
total = list()
good_person = list()
bad_person = list()
for i in range(1,n+1):
    t = int(input())
    A = list()
    for index in range(1,t+1):
        _input = input().split(" ")
        x = int(_input[0])
        y = int(_input[1])
        A.append((x, y))
    total.append(A)

for person in total:
    x = [x[0] for x in person]
    y = [y[1] for y in person]
    for index, a in enumerate(y):
        if a == 1:
            # good
            good_person.append(x[index])
        else:
            bad_person.append(x[index])
output = 0
# print(good_person)
# print(bad_person)
if sorted(good_person) == sorted(bad_person):
    output = 0
elif len(good_person) == 0:
    output = 1
elif len(good_person)< len(bad_person):
    output = 0
else:
    output = len(good_person) - len(bad_person)
print(output)

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
 
n = I()
ans = 0
lst = [[] for _ in range(n)]
for i in range(n):
    a = I()
    for j in range(a):
        x,y = LI()
        lst[i].append((x-1,y))
for i in range(2**n):
    b = [0]*n
    for j in range(n):
        if (i >> j) & 1:
            b[j] = 1
    flg = True
    for j in range(n):
        if b[j] == 0:
            continue
        for k,l in lst[j]:
            if l == 0:
                if b[k] == 1:
                    flg = False
                    break
            else:
                if b[k] == 0:
                    flg = False
                    break
        if not flg:
            break
    else:
        ans = max(ans,sum(b))
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted