Problem:


Score : 200 points

Problem Statement

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.

Constraints

All values in input are integers.

1 \leq A_{i, j} \leq 100

A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

A_{1, 1} A_{1, 2} A_{1, 3}
A_{2, 1} A_{2, 2} A_{2, 3}
A_{3, 1} A_{3, 2} A_{3, 3}
N
b_1
\vdots
b_N

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.



Sample input:
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
a = []
for i in  range(3):
    a_ = list(map(int,input().split()))
    a.append(a_)
n = int(input())

b = []
for i in range(n):
    b_ = int(input())
    b.append(b_)
# print(a)
# print(b)
for i in range(3):
    for k in range(3):
        for j in range(n):
                if a[i][k] == b[j]:
                    a[i][k] = 'ok'

conc = []

for i in range(3):
    for j in range(3):
        s = [i,j]
        if a[i][j] == 'ok':
            conc.append(s)

# print(a)
# print(conc)
x = []
y = []

if conc == []:
    print('No')
elif n <= 2:
    print('No')
else:
    for i in range(len(conc)):
        x.append(conc[i][0])
        y.append(conc[i][1])
    # print(x)
    # print(y)

    if (len(set(x)) or len(set(y)) == 3) and (len(set(x)) and len(set(y)) != 2):
        print('Yes')
    elif ((len(set(x)) and len(set(y))) == 3) and [1,1] in conc:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[0]*3]*3
    for i in range(3): #aを順番に見ていく
        for j in range(3):
            if a[i][j] in b:
                card[i][j] = 1
    #card
    if card[0][0] == card[0][1] == card[0][2]==1:#横の探索
        print("Yes")
        quit()
    elif card[0][0] == card[1][0] == card[2][0]==1:#縦の探索
        print("Yes")
        quit()
    elif card[0][0] == card[1][1] == card[2][2]==1:#0の時の斜め            
        print("Yes")
        quit()
    elif card[0][1] == card[1][1] == card[2][1]==1:# 縦
        print("Yes")
        quit()
    elif card[1][0] == card[1][1] == card[1][2]==1: # 
        print("Yes")
        quit()
    elif card[0][2] == card[1][1] == card[2][0] == 1:#2のときの斜
        print("Yes") 
        quit()
    elif card[0][2] == card[1][2] == card[2][2] == 1:
        print("Yes")
        quit()
    elif card[2][0] == card[2][1] == card[2][2] == 1:
        print("Yes")
        quit()  
    else:
        print("No")
        quit()
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = []
for i in  range(3):
    a_ = list(map(int,input().split()))
    a.append(a_)
n = int(input())

b = []
for i in range(n):
    b_ = int(input())
    b.append(b_)
# print(a)
# print(b)
for i in range(3):
    for k in range(3):
        for j in range(n):
                if a[i][k] == b[j]:
                    a[i][k] = 'ok'

conc = []

for i in range(3):
    for j in range(3):
        s = [i,j]
        if a[i][j] == 'ok':
            conc.append(s)

# print(a)
# print(conc)
x = []
y = []

if conc == []:
    print('No')
elif n <= 2:
    print('No')
else:
    for i in range(len(conc)):
        x.append(conc[i][0])
        y.append(conc[i][1])
    # print(x)
    # print(y)

    if (len(set(x)) or len(set(y))) == 3 and (len(set(x)) and len(set(y))) != 2:
        print('Yes')
    elif ((len(set(x)) and len(set(y))) == 3) and [1,1] in conc:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np


def main():
    card = np.array([[0] * 3] * 3)
    card[0] = input().split(' ')
    card[1] = input().split(' ')
    card[2] = input().split(' ')
    # print(card)

    bingos = np.array([[0] * 3] * 8)
    bingos[0] = card[0, 0], card[0, 1], card[0, 2]
    bingos[1] = card[1, 0], card[1, 1], card[1, 2]
    bingos[2] = card[2, 0], card[2, 1], card[2, 2]
    bingos[3] = card[0, 0], card[1, 0], card[2, 0]
    bingos[4] = card[0, 1], card[1, 1], card[2, 1]
    bingos[5] = card[0, 2], card[1, 2], card[2, 2]
    bingos[6] = card[0, 0], card[1, 1], card[2, 2]
    bingos[7] = card[0, 2], card[1, 1], card[2, 0]
    # print(bingos)

    n = int(input())
    inputs_ = []
    for _ in range(n):
        inputs_.append(int(input()))
    # print(inputs_)

    for bingo in bingos:
        print(bingo)
        if set(bingo).issubset(inputs_):
            print('Yes')
            return 0

    print('No')

    return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n1,n2,n3 = map(str,input().split())
n4,n5,n6 = map(str,input().split())
n7,n8,n9 = map(str,input().split())
n = int(input())

selects = []
for i in range(n):
    selects.append(input())
    
h1 = Counter()
h1[n1] = 0
h1[n2] = 0
h1[n3] = 0
h1[n4] = 0
h1[n5] = 0
h1[n6] = 0
h1[n7] = 0
h1[n8] = 0
h1[n9] = 0

for select in selects:
    if select in h1:
        h1[select] = 1

if (h1[n1] == 1 and h1[n2] == 1and h1[n3] == 1) \
or (h1[n4] == 1 and h1[n5] == 1and h1[n6] == 1) \
or (h1[n7] == 1 and h1[n8] == 1and h1[n9] == 1) \
or (h1[n1] == 1 and h1[n4] == 1and h1[n7] == 1) \
or (h1[n2] == 1 and h1[n5] == 1and h1[n8] == 1) \
or (h1[n3] == 1 and h1[n6] == 1and h1[n9] == 1) \
or (h1[n1] == 1 and h1[n5] == 1and h1[n9] == 1) \
or (h1[n3] == 1 and h1[n5] == 1and h1[n9] == 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
x = input()
y = input()
z = input()
xa = x.split(" ")
ya = y.split(" ")
za = z.split(" ")
A = np.array([xa,ya,za])
N = int(input())
b =[]
C = np.array([["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"]])
for i in range(1,N+1):
    b.append(input())
for m in range(0,3):
    for n in range(0,3):
        if A[m, n] in b:
            C[m,n] = "Maru"
tate = str(np.count_nonzero(C == 'Maru', axis=0))

yoko = str(np.count_nonzero(C == 'Maru', axis=1))

if "3" in tate or "3" in yoko:
    print('Yes')
elif C[0,0] == "Maru" and (C[1,1] == "Maru" and C[2,2] == "Maru"):
    print("Yes")
elif C[0,2] == "Maru" and (C[1,1] == "Maru" and C[2,0] == "Maru"):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

#入力処理、Aは行列、Bはリスト
A = [input().split() for l in range(3)]

B = []
for l in sys.stdin:
    if l == '\n':
        break
    B.append(l.rstrip('\n'))

#穴あきか判定
for i in B:
    A = np.where(A == i, 0, A)
#なんか0番目を判定してくれないから個別に判定
#ついでに0,1に全部を変換してビンゴ判定をらくする
A = np.where(A == B[0], 0, 1)

#ビンゴ判定
bingo = False
tate =0
#ななめ
if A[0][0]+A[1][1]+A[2][2] == 3 or A[0][2]+A[1][1]+A[2][0]==3:
    bingo = True

for i in range(3):
    #よこ
    if sum(A[i]) == 3:
        bingo = True
        break
    #たて
    for j in range(3):

        tate +=A[j][i]
        if tate == 3:
            bingo = True
            break
if bingo:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A_list = []

for i in range(3):
    a = list(map(int, input().split()))
    A_list.append(a)

N = int(input())
narray = np.zeros((3, 3), dtype=np.int)


for j in range(N):
    b = int(input())

    for n in range(3):
        for m in range(3): 
            if A_list[n][m] == b:
                narray[n, m] = 1


n_list = np.count_nonzero(narray == 1, axis = 0)
m_list = np.count_nonzero(narray == 1, axis = 1)

if np.any(n_list == 3) or np.any(m_list == 3):
    print('Yes')
    exit()

if narray[0, 0] == 1 and narray[1, 1] == 1 and narray[2, 2] == 1:
    print('Yes')
    exit()

if narray[0, 2] == 1 and narray[1, 1] == 1 and narray[2, 0] == 1:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A_list = []

for i in range(3):
    a = list(map(int, input().split()))
    A_list.append(a)

N = int(input())
narray = np.zeros((3, 3), dtype=np.int)


for j in range(N):
    b = int(input())

    for n in range(3):
        for m in range(3): 
            if A_list[n][m] == b:
                narray[n, m] = 1


n_list = np.count_nonzero(narray == 1, axis = 0)
m_list = np.count_nonzero(narray == 1, axis = 1)

print(narray)
print(n_list)
print(m_list)

if np.any(n_list == 3) or np.any(m_list == 3):
    print('Yes')
    exit()

if narray[0, 0] == 1 and narray[1, 1] == 1 and narray[2, 2] == 1:
    print('Yes')
    exit()

if narray[0, 2] == 1 and narray[1, 1] == 1 and narray[2, 0] == 1:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
a = []
for i in  range(3):
    a_ = list(map(int,input().split()))
    a.append(a_)
n = int(input())

b = []
for i in range(n):
    b_ = int(input())
    b.append(b_)
# print(a)
# print(b)
for i in range(3):
    for k in range(3):
        for j in range(n):
                if a[i][k] == b[j]:
                    a[i][k] = 'ok'

conc = []

for i in range(3):
    for j in range(3):
        s = [i,j]
        if a[i][j] == 'ok':
            conc.append(s)

# print(a)
# print(conc)
x = []
y = []

if conc == []:
    print('No')
elif n <= 2:
    print('No')
else:
    for i in range(len(conc)):
        x.append(conc[i][0])
        y.append(conc[i][1])
    # print(x)
    # print(y)

    if (len(set(x)) or len(set(y))) == 3 and (len(set(x)) and len(set(y))) != 2:
        print('Yes')
    elif (len(set(x)) and len(set(y))) == 3:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
num = 3
grid = []
for i in range(num):
    array = list(map(int, input().strip().split()))
    grid.append(array)

list1 = [grid[0][0], grid[1][0], grid[2][0]]
grid.append(list1)
list2 = [grid[0][1], grid[1][1], grid[2][1]]
grid.append(list2)
list3 = [grid[0][2], grid[1][2], grid[2][2]]
grid.append(list3)
list4 = [grid[0][0], grid[1][1], grid[2][2]]
grid.append(list4)
list5 = [grid[0][2], grid[1][1], grid[2][0]]
grid.append(list5)

N = int(input())
grid2 = []
for i in range(N):
    grid2.append(int(input()))

if set(grid[0]) <= set(grid2) == True:
  ans = 'Yes'
else:
  ans = 'No'
  if set(grid[1]) <= set(grid2) == True:
    ans = 'Yes'
  else:
    ans = 'No'
    if set(grid[2]) <= set(grid2) == True:
      ans = 'Yes'
    else:
      ans = 'No'
      if set(grid[3]) <= set(grid2) == True:
        ans = 'Yes'
      else:
        ans = 'No'
        if set(grid[4]) <= set(grid2) == True:
          ans = 'Yes'
        else:
          ans = 'No'
          if set(grid[5]) <= set(grid2) == True:
            ans = 'Yes'
          else:
            ans = 'No'
            if set(grid[6]) <= set(grid2) == True:
              ans = 'Yes'
            else:
              ans = 'No'
              if set(grid[7]) <= set(grid2) == False:
                ans = 'Yes'
              else:
                ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
A11,A12,A13 = map(int,input().split(" "))
A21,A22,A23 = map(int,input().split(" "))
A31,A32,A33 = map(int,input().split(" "))
N = int(input())
B = []
for i in range(N):
    b = int(input())
    B.append(b)
bingo = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
bingo = ",".join(map(str,bingo))
for i in B:
    i = str(i)
    if i in bingo:
        bingo = bingo.replace(i,"True")
    else:
        pass
    
Bingo = bingo.split(",")
Flag = False
if Bingo[0] == Bingo[1] == Bingo[2]=="True":
    Flag = True
if Bingo[3] == Bingo[4] == Bingo[5]=="True":
    Flag = True
if Bingo[6] == Bingo[7] == Bingo[8]=="True":
    Flag = True
if Bingo[0] == Bingo[3] == Bingo[6]=="True":
    Flag = True
if Bingo[1] == Bingo[4] == Bingo[7]=="True":
    Flag = True
if Bingo[2] == Bingo[5] == Bingo[8]=="True":
    Flag = True
if Bingo[0] == Bingo[4] == Bingo[8]=="True":
    Flag = True
if Bingo[2] == Bingo[4] == Bingo[6]=="True":
    Flag = True
else:
    pass
if Flag == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
    array = list(map(int, input().strip().split()))
    bingo.append(array)

N = int(input())
number = []

for j in range(N):
    number.append(int(input()))

result = []
for n in range(N):
    for t in range(3):
        for y in range(3):
            if(bingo[t][y] == number[n]):
                result.append([t,y])

bingo_a = 'No'
for t in range(3):
    t_a = 0
    for y in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                t_a += 1
    if(t_a == 3):
        bingo_a = 'Yes'

for y in range(3):
    y_a = 0
    for t in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                y_a += 1
    if(y_a == 3):
        bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 0):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 2):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 2):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 0):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

print(bingo_a)

Submission status: Wrong Answer

Solution code:
A = []
out = []
for x in range(3):
    A.append(list(map(int, input().split())))
    out.append([0, 0, 0])
N = int(input())
b = []
for B in range(N):
    b.append(int(input()))
for pick in b:
    for y in range(3):
        for x in range(3):
            if pick == A[y][x]:
                out[y][x] = 1

bingo = False
for x in range(3):
    if out[x][0] == 1 and out[x][1] and out[x][2]:
        bingo = True

for x in range(3):
    if out[0][x] == 1 and out[1][x] and out[2][x]:
        bingo = True

for x in range(3):
    if out[x][x] == 1:
        bingo = True

    if out[2 - x][x] == 1:
        bingo = True

if bingo:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
    array = list(map(int, input().strip().split()))
    bingo.append(array)

N = int(input())
number = []

for j in range(N):
    number.append(int(input()))

result = []
for n in range(N):
    for t in range(3):
        for y in range(3):
            if(bingo[t][y] == number[n]):
                result.append([t,y])

bingo_a = 'No'
for t in range(3):
    t_a = 0
    for y in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                t_a += 1
    if(t_a == 3):
        bingo_a = 'Yes'

for y in range(3):
    y_a = 0
    for y in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                y_a += 1
    if(y_a == 3):
        bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 0):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 2):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 2):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 0):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

print(bingo_a)

Submission status: Wrong Answer

Solution code:
num = 3
grid = []
for i in range(num):
    array = list(map(int, input().strip().split()))
    grid.append(array)

list1 = [grid[0][0], grid[1][0], grid[2][0]]
grid.append(list1)
list2 = [grid[0][1], grid[1][1], grid[2][1]]
grid.append(list2)
list3 = [grid[0][2], grid[1][2], grid[2][2]]
grid.append(list3)
list4 = [grid[0][0], grid[1][1], grid[2][2]]
grid.append(list4)
list5 = [grid[0][2], grid[1][1], grid[2][0]]
grid.append(list5)

N = int(input())
grid2 = []
for i in range(N):
    grid2.append(int(input()))

if set(grid[0]) <= set(grid2) == True:
  ans = 'Yes'
else:
  if set(grid[1]) <= set(grid2) == True:
    ans = 'Yes'
  else:
    if set(grid[2]) <= set(grid2) == True:
      ans = 'Yes'
    else:
      if set(grid[3]) <= set(grid2) == True:
        ans = 'Yes'
      else:
        if set(grid[4]) <= set(grid2) == True:
          ans = 'Yes'
        else:
          if set(grid[5]) <= set(grid2) == True:
            ans = 'Yes'
          else:
            if set(grid[6]) <= set(grid2) == True:
              ans = 'Yes'
            else:
              if set(grid[7]) <= set(grid2) == False:
                ans = 'Yes'
              else:
                ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
X = [[0 for i in range(3)] for j in range(3)]
for x in range(3):
    Y = list(map(int,input().split()))
#    print(Y)
    #print(Y[0])
    for y in range(3):
        X[x][y] = Y[y]
#        print(x,y,X[x][y],Y[y])
print(X)


N = int(input())
B = []
for x in range(N):
    B.append(int(input()))
#print(X)
#print(B)
for x in B:
    for y in range(3):
        for z in range(3):
            if(X[y][z] == x):
                X[y][z] = True
ans = "No"
for x in range(3):
    if(X[x][0] == True and X[x][1] == True and X[x][2] == True):
        ans = "Yes"
    if(X[0][x] == True and X[1][x] == True and X[2][x] == True):
        ans = "Yes"
if(X[0][0] == True and X[1][1] == True and X[2][2] == True):
    ans = "Yes"
if(X[0][2] == True and X[1][1] == True and X[2][0] == True):
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
A_list_yoko1 = list(map(int, input().split()))
A_list_yoko2 = list(map(int, input().split()))
A_list_yoko3 = list(map(int, input().split()))
N = int(input())
B_list = []
for i in range(N):
    B_list.append(int(input()))

A_list_tate1 = []
A_list_tate2 = []
A_list_tate3 = []
A_list_naname1 = []
A_list_naname2 = []

A_list_tate1.append(A_list_yoko1[0])
A_list_tate1.append(A_list_yoko2[0])
A_list_tate1.append(A_list_yoko3[0])
A_list_tate2.append(A_list_yoko1[1])
A_list_tate2.append(A_list_yoko2[1])
A_list_tate2.append(A_list_yoko3[1])
A_list_tate3.append(A_list_yoko1[2])
A_list_tate3.append(A_list_yoko2[2])
A_list_tate3.append(A_list_yoko3[2])
A_list_naname1.append(A_list_yoko1[0])
A_list_naname1.append(A_list_yoko2[1])
A_list_naname1.append(A_list_yoko3[2])
A_list_naname2.append(A_list_yoko1[2])
A_list_naname2.append(A_list_yoko2[1])
A_list_naname2.append(A_list_yoko3[0])

A_list_yoko1_c = []
A_list_yoko2_c = []
A_list_yoko3_c = []
A_list_tate1_c = []
A_list_tate2_c = []
A_list_tate3_c = []
A_list_naname1_c = []
A_list_naname2_c = []
for i in B_list:
    if i in A_list_yoko1:
        A_list_yoko1_c.append(A_list_yoko1.index(i))
    if i in A_list_yoko2:
        A_list_yoko2_c.append(A_list_yoko2.index(i))
    if i in A_list_yoko3:
        A_list_yoko3_c.append(A_list_yoko3.index(i))
    if i in A_list_tate1:
        A_list_tate1_c.append(A_list_tate1.index(i))
    if i in A_list_tate2:
        A_list_tate2_c.append(A_list_tate2.index(i))
    if i in A_list_tate3:
        A_list_tate3_c.append(A_list_tate3.index(i))
    if i in A_list_naname1:
        A_list_naname1_c.append(A_list_naname1.index(i))
    if i in A_list_naname2:
        A_list_naname2_c.append(A_list_naname2.index(i))

if list(A_list_naname1_c) == 3 or list(A_list_naname2_c) == 3 or list(A_list_tate1_c) == 3 or list(A_list_tate2_c) == 3 or list(A_list_tate3_c) == 3 or list(A_list_yoko1_c) == 3 or list(A_list_yoko2_c) == 3 or list(A_list_yoko3_c) == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
X = [[0 for i in range(3)] for j in range(3)]
for x in range(3):
    Y = list(map(int,input().split()))
#    print(Y)
    #print(Y[0])
    for y in range(3):
        X[x][y] = Y[y]
#        print(x,y,X[x][y],Y[y])
print(X)


N = int(input())
B = []
for x in range(N):
    B.append(int(input()))
#print(X)
#print(B)
for x in B:
    for y in range(3):
        for z in range(3):
            if(X[y][z] == x):
                X[y][z] = "Bingo"
ans = "No"
for x in range(3):
    if(X[x][0] == "Bingo" and X[x][1] == "Bingo" and X[x][2]):
        ans = "Yes"
    if(X[0][x] == "Bingo" and X[1][x] == "Bingo" and X[2][x]):
        ans = "Yes"
if(X[0][0] == "Bingo" and X[1][1] == "Bingo" and X[2][2]):
    ans = "Yes"
if(X[0][2] == "Bingo" and X[1][1] == "Bingo" and X[2][0]):
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
def checkBingo(bList):
    ret = "No"
    for i in range(3):
        for j in range(3):
            if bList[i][j] != -1:
                break
            ret = "Yes"
    for i in range(3):
        if bList[0][i] == -1 and bList[1][i] == -1 and bList[2][i] == -1:
            ret = "Yes"
    if bList[0][0] == -1 and bList[1][1] == -1 and bList[2][2] == -1:
        ret = "Yes"
    if bList[0][2] == -1 and bList[1][1] == -1 and bList[2][0] == -1:
        ret = "Yes"
    return ret

def deleteNumber(bList, number):
    for i in range(3):
        for j in range(3):
            if bList[i][j] == number:
                bList[i][j] = -1

raw1 = map(int, input().split())
raw2 = map(int, input().split())
raw3 = map(int, input().split())
bingo = [list(raw1), list(raw2), list(raw3)]

n = int(input())
for i in range(n):
    number = int(input())
    deleteNumber(bingo, number)

print("{}".format(checkBingo(bingo)))

Submission status: Wrong Answer

Solution code:
f_row = list(input().split())
s_row = list(input().split())
t_row = list(input().split())
N = int(input())
chosen_nums = [input() for _ in range(N)]

f_dict = dict()
for key in f_row:
    f_dict[key] = False
s_dict = dict()
for key in s_row:
    s_dict[key] = False
t_dict = dict()
for key in t_row:
    t_dict[key] = False

for num in chosen_nums:
    if num in f_dict:
        f_dict[num] = True
    if num in s_dict:
        s_dict[num] = True
    if num in t_dict:
        t_dict[num] = True

f_rows = list(f_dict.values())
s_rows = list(s_dict.values())
t_rows = list(t_dict.values())

f_cols = [f_rows[0], s_rows[0], t_rows[0]]
s_cols = [f_rows[1], s_rows[1], t_rows[1]]
t_cols = [f_rows[2], s_rows[2], t_rows[2]]

out = 'No'

if all(f_rows) or all(s_rows) or all(t_rows) or all(f_cols) or all(s_cols) or all(t_cols):
    out = 'Yes'
elif f_rows[0] and s_rows[1] and t_rows[2]:
    out = 'Yes'
elif f_rows[2] and s_rows[1] and t_rows[0]:
    out = 'Yes'

print(out)

Submission status: Wrong Answer

Solution code:
card = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == num:
                card[i][j] = 0
print(card)
for i in range(3):
    if  (card[0][i] == 0 and card[1][i] == 0 and card[2][i] == 0) or\
        (card[i][0] == 0 and card[i][1] == 0 and card[i][2] == 0):
        print("Yes")
        exit()
if  (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or\
    (card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
def checkBingo(bList):
    ret = "No"
    for i in range(3):
        for j in range(3):
            if bList[i][j] != -1:
                break
            ret = "Yes"
    for i in range(3):
        for j in range(3):
            if bList[j][i] != -1:
                break
            ret = "Yes"
    for i in range(3):
        if bList[i][i] != -1:
            break
        ret = "Yes"
    for i in range(3):
        if bList[i][2-i] != -1:
            break
        ret = "Yes"
    return ret

def deleteNumber(bList, number):
    for i in range(3):
        for j in range(3):
            if bList[i][j] == number:
                bList[i][j] = -1

raw1 = map(int, input().split())
raw2 = map(int, input().split())
raw3 = map(int, input().split())
bingo = [list(raw1), list(raw2), list(raw3)]

n = int(input())
for i in range(n):
    number = int(input())
    deleteNumber(bingo, number)

print("{}".format(checkBingo(bingo)))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

A = []
b = []
B = [[0, 0, 0] for _ in range(3)]

for _ in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

for _ in range(N):
    b.append(int(input()))

for value in b:
    for i in range(3):
        for j in range(3):
            if A[i][j] == value:
                B[i][j] = 1

bingo = False

if B[0][0] == 1:
    if B[0][1] == 1 and B[0][1] == 1:
        bingo = True
    if B[1][0] == 1 and B[2][0] == 1:
        bingo = True
    if B[1][1] == 1 and B[2][2] == 1:
        bingo = True

if B[1][1] == 1:
    if B[1][0] == 1 and B[1][2] == 1:
        bingo = True
    if B[0][1] == 1 and B[2][1] == 1:
        bingo = True
    if B[0][2] == 1 and B[2][0] == 1:
        bingo = True   

if B[2][2] == 1:
    if B[0][2] == 1 and B[1][2] == 1:
        bingo = True
    if B[2][0] == 1 and B[2][1] == 1:
        bingo = True
    
if bingo:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

A = []
b = []
B = [[0, 0, 0] for _ in range(3)]

for _ in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

for _ in range(N):
    b.append(int(input()))

for value in b:
    for i in range(3):
        for j in range(3):
            if A[i][j] == value:
                B[i][j] = 1

bingo = False

if B[0][0] == 1:
    if B[0][1] == 1 and B[0][1] == 1:
        bingo = True
    if B[1][0] == 1 and B[2][0] == 1:
        bingo = True
    if B[1][1] == 1 and B[2][2] == 1:
        bingo = True

if B[1][1] == 1:
    if B[1][0] == 1 and B[1][2] == 1:
        bingo = True
    if B[0][1] == 1 and B[2][1] == 1:
        bingo = True
    if B[0][2] == 1 and B[2][0] == 1:
        bingo = True   

if B[2][2] == 1:
    if B[0][2] == 1 and B[1][2] == 1:
        bingo = True
    if B[2][0] == 1 and B[2][1] == 1:
        bingo = True
    
if bingo:
    print('Yes')
else:
    print('No')

print(B)

Submission status: Wrong Answer

Solution code:
A11,A12,A13 = map(int,input().split(" "))
A21,A22,A23 = map(int,input().split(" "))
A31,A32,A33 = map(int,input().split(" "))
N = int(input())
B = []
for i in range(N):
    b = int(input())
    B.append(b)
bingo = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
bingo = ",".join(map(str,bingo))
for i in B:
    i = str(i)
    if i in bingo:
        bingo = bingo.replace(i,"True")
    else:
        pass
    
Bingo = bingo.split(",")
Flag = False
if Bingo[0] == Bingo[1] == Bingo[2]=="True":
    Flag = True
if Bingo[3] == Bingo[4] == Bingo[6]=="True":
    Flag = True
if Bingo[6] == Bingo[7] == Bingo[8]=="True":
    Flag = True
if Bingo[0] == Bingo[3] == Bingo[6]=="True":
    Flag = True
if Bingo[1] == Bingo[4] == Bingo[7]=="True":
    Flag = True
if Bingo[2] == Bingo[5] == Bingo[8]=="True":
    Flag = True
if Bingo[0] == Bingo[4] == Bingo[8]=="True":
    Flag = True
if Bingo[2] == Bingo[4] == Bingo[6]=="True":
    Flag = True
else:
    pass
if Flag == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
n1,n2,n3 = map(str,input().split())
n4,n5,n6 = map(str,input().split())
n7,n8,n9 = map(str,input().split())
n = int(input())

selects = []
for i in range(n):
    selects.append(input())
    
print(selects)
h1 = Counter()
h1[n1] = 0
h1[n2] = 0
h1[n3] = 0
h1[n4] = 0
h1[n5] = 0
h1[n6] = 0
h1[n7] = 0
h1[n8] = 0
h1[n9] = 0

for select in selects:
    if select in h1:
        h1[select] = 1
print(h1)

if (h1[n1] == 1 and h1[n2] == 1and h1[n3] == 1) \
or (h1[n4] == 1 and h1[n5] == 1and h1[n6] == 1) \
or (h1[n7] == 1 and h1[n8] == 1and h1[n9] == 1) \
or (h1[n1] == 1 and h1[n4] == 1and h1[n7] == 1) \
or (h1[n2] == 1 and h1[n5] == 1and h1[n8] == 1) \
or (h1[n3] == 1 and h1[n6] == 1and h1[n9] == 1) \
or (h1[n1] == 1 and h1[n5] == 1and h1[n9] == 1) \
or (h1[n3] == 1 and h1[n5] == 1and h1[n9] == 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
num = 3
grid = []
for i in range(num):
    array = list(map(int, input().strip().split()))
    grid.append(array)

list1 = [grid[0][0], grid[1][0], grid[2][0]]
grid.append(list1)
list2 = [grid[0][1], grid[1][1], grid[2][1]]
grid.append(list2)
list3 = [grid[0][2], grid[1][2], grid[2][2]]
grid.append(list3)
list4 = [grid[0][0], grid[1][1], grid[2][2]]
grid.append(list4)
list5 = [grid[0][2], grid[1][1], grid[2][0]]
grid.append(list5)

N = int(input())
grid2 = []
for i in range(N):
    grid2.append(int(input()))

if set(grid[0]) <= set(grid2) == False:
  if set(grid[1]) <= set(grid2) == False:
    if set(grid[2]) <= set(grid2) == False:
      if set(grid[3]) <= set(grid2) == False:
        if set(grid[4]) <= set(grid2) == False:
          if set(grid[5]) <= set(grid2) == False:
            if set(grid[6]) <= set(grid2) == False:
              if set(grid[7]) <= set(grid2) == False:
                ans = 'No'
else:
  ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
#Input
l_A =  [[0 for i in range(3)] for j in range(3)]
l_A[0] = list(map(int, input().split()))
l_A[1] = list(map(int, input().split()))
l_A[2] = list(map(int, input().split()))

def detect_BINGO(l_Atf):
    #print(l_Atf)
    #横
    for i in range(3):
        f_detect = True
        for j in range(3):
            #print(f_detect, l_Atf[i][j])
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            #print("横" + str(i))
            return True
    #縦
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[j][i]
        if(f_detect):
            #print("縦" + str(i))
            return True
    #斜
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        #print("斜＼")
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][3-1-i]
    if(f_detect):
        #print("斜／")
        return True
    
    #BINGOなし
    return False

#Process
l_Atf = [[False for i in range(3)] for j in range(3)]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if(l_A[j][k] == b):
                l_Atf[j][k] = True
    #print(l_Atf)

f_bingo = detect_BINGO(l_Atf)

#Output
if(f_bingo):
    print("Yes")
else:
    print("no")