Problem: We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.  The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Submission attempts (in order):
bingo_l = []
b_flg = 0
        
for _ in range(3):
    bingo_l.append(list(map(int, input().split())))

N = int(input())

kekka_l = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == bingo_l[i][j]:
                kekka_l[i][j] = 1
                break

for i in range(3):
    if sum(kekka_l[i]) == 3:
        b_flg = 1
        break

sum = 0

for j in range(3):
    for i in range(3):
        sum += kekka_l[i][j]
        if sum == 3:
            b_flg = 1
            break

if kekka_l[0][0] + kekka_l[1][1] + kekka_l[2][2] == 3:
    b_flg = 1

if kekka_l[0][2] + kekka_l[1][1] + kekka_l[2][0] == 3:
    b_flg = 1

if b_flg == 1:
    print('yes')
else:
    print('No')


bingo_l = []
        
for _ in range(3):
    bingo_l.append(list(map(int, input().split())))

N = int(input())

kekka_l = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == bingo_l[i][j]:
                kekka_l[i][j] = 1
                break

for i in range(3):
    if sum(kekka_l[i]) == 3:
        b_flg = 1
        break

sum = 0

for j in range(3):
    for i in range(3):
        sum += kekka_l[i][j]
        if sum == 3:
            b_flg = 1
            break

if kekka_l[0][0] + kekka_l[1][1] + kekka_l[2][2] == 3:
    b_flg = 1

if kekka_l[0][2] + kekka_l[1][1] + kekka_l[2][0] == 3:
    b_flg = 1

if b_flg == 1:
    print('yes')
else:
    print('No')

 

bingo_l = []
b_flg = 0
        
for _ in range(3):
    bingo_l.append(list(map(int, input().split())))

N = int(input())

kekka_l = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == bingo_l[i][j]:
                kekka_l[i][j] = 1
                break

for i in range(3):
    if sum(kekka_l[i]) == 3:
        b_flg = 1
        break

sum = 0

for j in range(3):
    for i in range(3):
        sum += kekka_l[i][j]
        if sum == 3:
            b_flg = 1
            break

if kekka_l[0][0] + kekka_l[1][1] + kekka_l[2][2] == 3:
    b_flg = 1

if kekka_l[0][2] + kekka_l[1][1] + kekka_l[2][0] == 3:
    b_flg = 1

if b_flg == 1:
    print('yes')
else:
    print('No')


card = []
for i in range(3):
    card.append(list(map(int, input().split())))

N = int(input())

result = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == card[i][j]:
                result[i][j] = 1

judge = 'No'

for i in range(3):
    if result[i][0] * result[i][1] * result[i][2] == 1:
        judge = 'Yes'

for i in range(3):
    if result[0][i] * result[1][i] * result[2][i] == 1:
        judge = 'Yes'

if result[0][0] * result[1][1] * result[2][2] == 1:
    judge = 'Yes'

if result[0][2] * result[1][1] * result[2][0] == 1:
    judge = 'Yes'

print(judge)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted