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

g_list = [[]]
for i in range(N):
    for j in range(N):
        g_list[i][j] = -1

for i in range(N):
    m = int(input())
    for j in range(m):
        a_x = list(map(int, input().split()))
        a = a_x[0]
        a -= 1
        x = a_x[1]
        g_list[i][a] = x

ans = 0

for i in range(1<<N):
    d = [0 for l in range(N)]
    for j in range(N):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j]:
            for k in range(N):
                if g_list[j][k] == -1:
                    continue
                if g_list[j][k] != d[k]:
                    ok = False
    if ok:
        total = sum(bin(i)[2:])
        ans = max(ans, total)

print(ans)

def judge(bit, N, a_x_y_dict):

    for i in range(N):
        if not (bit & (1 << i)):
            continue

        for key, values in a_x_y_dict.items():
            for v in values:
                x = v[0]
                y = v[1]

                if y == 1 and not (bit & (1 << x)):
                    return False
                if y == 0 and (bit & (1 << x)):
                    return False

    return True

N = int(input())

a_x_y_dict = {}
for i in range(N):
    a = int(input())
    x_y_list = []

    for j in range(a):
        x, y = list(map(int, input().split()))
        x_y_list.append((x,y))
    a_x_y_dict[i] = x_y_list

res = 0

for bit in range(1 << N):
    if judge(bit, N, a_x_y_dict):
        count = 0
        for i in range(N):
            if bit & (1 << N):
                count += 1
        res = max(res, count)

print(res)


def judge(bit, N, a_x_y_dict):

    for i in range(N):
        if not (bit & (1 << i)):
            continue

        for values in a_x_y_dict[i]:
            x = values[0]
            y = values[1]

            if y == 1 and not (bit & (1 << x)):
                return False
            if y == 0 and (bit & (1 << x)):
                return False
    return True


N = int(input())

a_x_y_dict = {}
for i in range(N):
    a = int(input())
    x_y_list = []

    for j in range(a):
        x, y = list(map(int, input().split()))
        x_y_list.append((x, y))
    a_x_y_dict[i] = x_y_list

res = 0

for bit in range(1 << N):
    if judge(bit, N, a_x_y_dict):
        count = 0
        for i in range(N):
            if bit & (1 << i):
                count += 1
        res = max(res, count)

print(res)

N = int(input())

g_list = [[-1 for i in range(N)] for j in range(N)]

for i in range(N):
    m = int(input())
    for j in range(m):
        a_x = list(map(int, input().split()))
        a = a_x[0]
        a -= 1
        x = a_x[1]
        g_list[i][a] = x

ans = 0

for i in range(1 << N):
    d = [0 for l in range(N)]
    for j in range(N):
        if i >> j & 1:
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j]:
            for k in range(N):
                if g_list[j][k] == -1:
                    continue
                if g_list[j][k] != d[k]:
                    ok = False
    if ok:
        total = list(bin(i)[2:].rjust(N, '0'))
        count = 0
        for t in total:
            if t == '1':
                count += 1
        ans = max(ans, count)

print(ans)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted