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:
#ABC157.B
A = [input().split()for i in range(3)]
N = int(input())
b = [int(input())for _ in range(N)]
if (A[0][0] in b)and (A[0][1]in b)and (A[0][2] in b):
    print('Yes')
elif (A[1][0]in b)and(A[1][1] in b)and(A[1][2]in b):
    print('Yes')
elif (A[2][0]in b)and(A[2][1]in b)and (A[2][2]in b):
    print('Yes')
elif (A[0][0]in b)and(A[1][0]in b)and(A[2][0]in b):
    print('Yes')
elif (A[0][1]in b)and (A[1][1]in b)and(A[2][1]in b):
    print('Yes')
elif (A[0][2] in b)and (A[1][2]in b)and(A[2][2]in b):
    print('Yes')
elif (A[0][0]in b)and (A[1][1]in b)and(A[2][2]in b):
    print('Yes')
elif (A[0][2]in b)and (A[1][1]in b)and(A[2][0]in b):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
B = [[0,0,0],[0,0,0],[0,0,0]]

ans = 'No'
for i, row in enumerate(A):
    for j, value in enumerate(row):
        if value in b:
            B[i][j] = 1
print(B)
if B[0][0]==B[0][1]==B[0][2]==1 or B[1][0]==B[1][1]==B[1][2]==1 or B[2][0]==B[2][1]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][0]==B[2][0]==1 or B[0][1]==B[1][1]==B[2][1]==1 or B[0][2]==B[1][2]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][1]==B[2][2]==1 or B[0][2]==B[1][1]==B[2][0]==1:
    ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
B = [[0,0,0],[0,0,0],[0,0,0]]

ans = 'No'
for i, row in enumerate(A):
    for j, value in enumerate(row):
        if value in b:
            B[i][j] = 1
if B[0][0]==B[0][1]==B[0][2]==1 or B[1][0]==B[1][1]==B[1][2]==1 or B[2][0]==B[2][1]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][0]==B[2][0]==1 or B[0][1]==B[1][1]==B[2][1]==1 or B[0][2]==B[1][2]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][1]==B[2][2]==1 or B[2][2]==B[1][1]==B[2][0]==1:
    ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
B = [[0,0,0],[0,0,0],[0,0,0]]

ans = 'No'
for i, row in enumerate(A):
    for j, value in enumerate(row):
        if value in b:
            B[i][j] = 1
if all(B[0]) or all(B[1]) or all(B[2]):
    ans = 'Yes'
elif B[0][0]==B[1][0]==B[2][0]==1 or B[0][1]==B[1][1]==B[2][1]==1 or B[0][2]==B[1][2]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][1]==B[2][2]==1 or B[2][2]==B[1][1]==B[2][0]==1:
    ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
B = [[0,0,0],[0,0,0],[0,0,0]]

ans = 'No'
for i, row in enumerate(A):
    for j, value in enumerate(row):
        if value in b:
            B[i][j] = 1
if all(B[0]) or all(B[1]) or all(B[2]):
    ans = 'Yes'
elif B[0][0]==B[1][0]==B[2][0]==1 or B[0][1]==B[1][1]==B[2][1]==1\
or B[0][2]==B[1][2]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][1]==B[2][2]==1 or B[2][2]==B[1][1]==B[2][0]==1:
    ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
B = [[0,0,0],[0,0,0],[0,0,0]]

ans = 'No'
for i, row in enumerate(A):
    for j, value in enumerate(row):
        if value in b:
            B[i][j] = 1
if B[0]==1 or B[1]==1 or B[2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][0]==B[2][0]==1 or B[0][1]==B[1][1]==B[2][1]==1\
or B[0][2]==B[1][2]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][1]==B[2][2]==1 or B[2][2]==B[1][1]==B[2][0]==1:
    ans = 'Yes'
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())

card=[a11,a12,a13,a21,a22,a23,a31,a32,a33]
def isBingo():
   if ( (card[0] == -1 and card[1] == -1 and card[2] == -1) \
      or (card[3] == -1 and card[4] == -1 and card[5] == -1) \
      or (card[6] == -1 and card[7] == -1 and card[8] == -1) \
      or (card[0] == -1 and card[3] == -1 and card[6] == -1) \
      or (card[1] == -1 and card[4] == -1 and card[7] == -1) \
      or (card[2] == -1 and card[5] == -1 and card[8] == -1) \
      or (card[0] == -1 and card[4] == -1 and card[8] == -1) \
      or (card[2] == -1 and card[4] == -1 and card[6] == -1) \
      ):
      return True
   else:
      return False
    
for i in range(n):
  if i in card:
    card[card.index(i)]=-1
if( isBingo()):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]
def checkBingo(holes):
    holes_x = [list(x) for x in zip(*holes)]
    _a,_b = True,True
    for i in range(3):
        if not None in holes[i] or not None in holes_x[i]:# 縦横
            return True
        #斜め
        if None is holes[i][i]:_a=False
        if None is holes[i][-i]: _b=False
    return (_a ==True or _b == True)
bingo = []
holes = []
for i in range(3):
    bingo += [getInput()]
for i in bingo:
    holes += [[None for n in i]]
N = getInput()[0]
for i in range(N):
    num = getInput()[0]
    for h in range(3):
        for w in range(3):
            if num == bingo[h][w]:
                holes[h][w] = 1
                break
    if checkBingo(holes):
        print('Yes')
        sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
A1=input().split(" ")
A2=input().split(" ")
A3=input().split(" ")
N=int(input())
B=[input() for _ in range(N)]

A=[A1,A2,A3]

for i in range(3):
    for j in range(3):
        for k in range(N):
            if B[k]==A[i][j]:
                A[i][j]=="OK"

A[0][0]==A[1][1]==A[2][2] or A[2][0]==A[1][1]==A[0][2]
Ans="Yes"

for i in range(3):
    if A[i][1]==A[i][2]==A[i][0]:
        print("Yes")
    elif A[1][i]==A[2][i]==A[0][i]:
        print("Yes")


print("Yes" if Ans=="Yes" else "No")

Submission status: Wrong Answer

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

for i in range(n):
    b = int(input())
     #ビンゴの数字
    for j in range(3):
      for k in range(3):
        if A[j][k]==b:
            A[j][k]==-1 #ビンゴ空いたら-1とする

if A[0][0]==A[0][1]==A[0][2]==-1  or A[1][0]==A[1][1]==A[1][2]==-1 or A[2][0]==A[2][1]==A[2][2]==-1:
    print("Yes")
if A[0][0]==A[1][0]==A[2][0]==-1  or A[0][1]==A[1][1]==A[2][1]==-1 or A[0][2]==A[1][2]==A[2][2]==-1:
    print("Yes")
if A[0][0]==A[1][2]==A[2][2]==-1  or A[0][2]==A[1][1]==A[2][0]==-1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a = np.array(a)
b = np.array(b)
  
for i in range(n) :
  num = b[i]
  for j in range(3) :
    for k in range(3) :
      if num == a[j][k] :
        a[j][k] = 0
        break
        
ans = 'No'
for i in range(3) :
  if a[:,i].all() == 0 or a[i,:].all() == 0 :
    ans = 'Yes'
    
af = np.fliplr(a)
if np.diag(a).all() == 0 or np.diag(af).all() == 0 :
  ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
card = {}
bingo = {1:False,2:False,3:False,4:False,5:False,6:False,7:False,8:False,9:False}
for i in range(3):
    row = list(map(int, input().split()))
    card[i * 3 + 1] = row[0]
    card[i * 3 + 2] = row[1]
    card[i * 3 + 3] = row[2]

n = int(input())
for i in range(n):
    num = int(input())
    keys = [k for k, v in card.items() if v == num]
    if len(keys) > 0:
        bingo[keys[0]] = True

hit_keys = [k for k, v in bingo.items() if v]
if len(hit_keys) >= 3 and ((1 in hit_keys and 2 in hit_keys and 3 in hit_keys) or \
    (4 in hit_keys and 5 in hit_keys and 6 in hit_keys) or\
    (7 in hit_keys and 8 in hit_keys and 9 in hit_keys) or\
    (1 in hit_keys and 4 in hit_keys and 5 in hit_keys) or\
    (2 in hit_keys and 5 in hit_keys and 8 in hit_keys) or\
    (3 in hit_keys and 6 in hit_keys and 9 in hit_keys) or\
    (1 in hit_keys and 5 in hit_keys and 9 in hit_keys) or\
    (3 in hit_keys and 5 in hit_keys and 7 in hit_keys)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    A.append(list(map(int,input().split())))
N = int(input())
number = [int(input())for i in range(N)]
bingo = [[0,0,0],[0,0,0],[0,0,0]]
for i in number:
    for j in range(3):
        for k in range(3):
            if i == A[j][k]:
                bingo[j][k]=1

if bingo[0][0]+bingo[1][0]+bingo[2][0]==3 or bingo[0][1]+bingo[1][1]+bingo[2][1]==3 or bingo[0][2]+bingo[1][2]+bingo[2][2]==3:
        print("Yes")
        exit()
 
elif bingo[0][0]+bingo[1][1]+bingo[2][2]==3 or bingo[0][2]+bingo[1][1]+bingo[2][0]==3:
    print("Yes")
    exit()
    
print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]


# 穴あけ
for i in range(3):
    for j in range(3):
        if (A[i][j] in B):
            A[i][j] = True
        else:
            A[i][j] = False

print(A)

for i in range(3):
    if A[i][0] and A[i][1] and A[i][2]:
        print("Yes")
        exit()

    if A[0][i] and A[1][i] and A[2][i]:
        print("Yes")
        exit()

if A[0][0] and A[1][1]and A[2][2]:
    print("Yes")
    exit()

if A[2][0] and A[1][1] and A[0][2]:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]


isBingo = False

# 穴あけ
for i in range(2):
    for j in range(2):
        if (A[i][j] in B):
            A[i][j] = True
        else:
            A[i][j] = False

cnt = 0

# 列方向
for i in range(2):
    for j in range(2):
        if (A[i][j]):
            cnt += 1
    if (cnt == 2):
        print("Yes")
        exit()
    cnt = 0

# 行方向
for j in range(2):
    for i in range(2):
        if (A[i][j]):
            cnt += 1
    if (cnt == 2):
        print("Yes")
        exit()
    cnt = 0

# 左上から
for i in range(2):
    if (A[i][j]):
        cnt += 1
    if (cnt == 2):
        print("Yes")
        exit()
    cnt = 0

# 右上から
if (A[0][2] and A[1][1] and A[2][0]):
    print("Yes")
    exit()


print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]



isBingo = False

# 穴あけ
for i in range(2):
    for j in range(2):
        if (A[i][j] in B):
            A[i][j] = True
        else:
            A[i][j] = False

cnt = 0

# 列方向
for i in range(2):
    for j in range(2):
        if (A[i][j]):
            cnt += 1
    if (cnt == 2):
        print("retu")
        print("yes")
        exit()
    cnt = 0

# 行方向
for j in range(2):
    for i in range(2):
        if (A[i][j]):
            cnt += 1
    if (cnt == 2):
        print("gyo")
        print("yes")
        exit()
    cnt = 0

# 左上から
for i in range(2):
    if (A[i][j]):
        cnt += 1
    if (cnt == 2):
        print("naname")
        print("yes")
        exit()
    cnt = 0

# 右上から
if (A[0][2] and A[1][1] and A[2][0]):
    print("migiue")
    print("yes")
    exit()


print("no")

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())
list =[]
for i in range(n-1):
  Bi =int(input())
  list.append(Bi)
if (A11 in list) and (A12 in list) and (A13 in list):
  print('Yes')
elif (A21 in list) and (A22 in list) and (A23 in list):
  print('Yes')
elif (A31 in list) and (A32 in list) and (A33 in list):
  print('Yes')
elif (A11 in list) and (A21 in list) and (A31 in list):
  print('Yes')
elif (A12 in list) and (A22 in list) and (A32 in list):
  print('Yes')
elif (A13 in list) and (A23 in list) and (A33 in list):
  print('Yes')
elif (A11 in list) and (A22 in list) and (A33 in list):
  print('Yes')
elif (A31 in list) and (A22 in list) and (A13 in list):
  print('Yes')
else:
  print('No')

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())
list =[]
for i in range(n-1):
  Bi =int(input())
  list.append(Bi)
if ([A11, A12, A13] in list):
  print('Yes')
elif ([A21, A22, A23] in list):
  print('Yes')
elif ([A31, A32, A33] in list):
  print('Yes')
elif ([A11, A21, A31] in list): 
  print('Yes')
elif ([A12, A22, A32] in list): 
  print('Yes')
elif ([A13, A23, A33] in list):
  print('Yes')
elif ([A11, A22, A33] in list): 
  print('Yes')
elif ([A13 ,A22, A31] in list):
  print('Yes')
else:
  print('No')

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())
list =[]
for i in range(n-1):
  Bi =int(input())
  list.append(Bi)
if ([A11, A12, A13] in list) or ([A21, A22, A23] in list) or ([A31, A32, A33] in list) or ([A11, A21, A31] in list) or ([A12, A22, A32] in list) or ([A13, A23, A33] in list) or ([A11, A22, A33] in list) or ([A13 ,A22, A31] in list):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    A += list(map(int, input().split()))
N = int(input())
for i in range(N-1):
    b = int(input())
    if b in A:
        A = [0 if num == b else num for num in A]
bingo_check = [[0, 1, 2],
               [0, 3, 6],
               [0, 4, 8],
               [1, 4, 7],
               [2, 4, 6],
               [2, 5, 8],
               [3, 4, 5],
               [6, 7, 8]]
no_check = 1
for check in bingo_check:
    row = [A[i] for i in check]
    if not sum(row):
        print("Yes")
        no_check = 0
        break
if no_check:
    print("No")

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    A += list(map(int, input().split()))
N = int(input())
for i in range(N-1):
    b = int(input())
    if b in A:
        A = [0 if num == b else num for num in A]
    print(A)
bingo_check = [[0, 1, 2],
               [0, 3, 6],
               [0, 4, 8],
               [1, 4, 7],
               [2, 4, 6],
               [2, 5, 8],
               [3, 4, 5],
               [6, 7, 8]]
no_check = 1
for check in bingo_check:
    row = [A[i] for i in check]
    if not sum(row):
        print("Yes")
        no_check = 0
        break
if no_check:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
S = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
for _ in range(n):
    S = np.where(S==int(input()), 0, S)
if min(np.sum(S, axis=0))==0 or min(np.sum(S, axis=1))==0:
    print('Yes')
    exit()
if (S[0][0] == 0 and S[1][1] == 0 and S[2][2]) or (S[2][0] == 0 and S[1][1] == 0 and S[0][2]):
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:
a = []
c = [[0]*3 for i in range(3)]
for i in range(3):
    tmp = list(map(int,input().split()))
    a.append(tmp)
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                c[j][k] = 1
if (c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1
    or c[0][0] == 1 and c[0][1] == 1 and c[0][2] == 1
    or c[1][0] == 1 and c[1][1] == 1 and c[1][2] == 1
    or c[2][0] == 1 and c[2][1] == 1 and c[2][2] == 1
    or c[0][0] == 1 and c[1][0] == 1 and c[2][0] == 1
    or c[0][1] == 1 and c[1][1] == 1 and c[2][1] == 1
    or c[0][2] == 1 and c[1][2] == 1 and c[2][2] == 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = []

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


N = int(input())
nums = set()
for _ in range(N):
  n = int(input())
  nums.add(n)

for row in A:
  if len(set(row).difference(nums)) == 0:
    print('Yes')
    exit()
for col in range(len(A[0])):
  nums_in_col = set()
  for row in range(len(A)):
    nums_in_col.add(A[row][col])
  if len(nums_in_col.difference(nums)) == 0:
    print('Yes')
    exit()

nums_ = set()
for i in range(len(A)):
  nums_.add(A[i][i])
if len(nums_.difference(nums)) == 0:
  print('Yes')
  exit()

nums_ = set()
for i in range(len(A)-1, -1, -1):
  for j in range(len(A)):
    nums_.add(A[i][j])

if len(nums_.difference(nums)) == 0:
  print('Yes')
  exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

def checkBingo(holes):
    holes_x = [list(x) for x in zip(*holes)]
    _a,_b = True,True

    for i in range(3):
        if not None in holes[i] or not None in holes_x[i]:# 縦横
            return True
        #斜め
        if None is holes[i][i]:_a=False
        if None is holes[-i][-i]: _b=False

    return (_a ==True or _b == True)

bingo = []
holes = []
for i in range(3):
    bingo += [getInput()]

for i in bingo:
    holes += [[None for n in i]]

N = getInput()[0]
for i in range(N):
    num = getInput()[0]
    for h in range(3):
        for w in range(3):
            # print("h:", h, ", w:", w)
            if num == bingo[h][w]:
                holes[h][w] = 1
                break
    if checkBingo(holes):
        print('Yes')
        sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
a = []
[a.append(list(map(int, input().split()))) for _ in range(3)]
n = int(input())
b = [int(input())for _ in range(n)]
for i in b:
  for j in range(3):
    for k in range(3):
      if a[j][k] == i:
        a[j][k] = 1
ans = 0
count =0
for j in range(3):
  if a[j].count(1) == 3:
    ans += 1
  elif (a[0][j] == a[1][j] == a[2][j]) == 1:
    ans += 1
  elif (a[0][0] == a[1][1] == a[2][2]) == 1:
    ans += 1
  elif (a[0][2] == a[1][1] == a[2][1]) == 1:
    ans += 1
if ans > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a = []
[a.append(list(map(int, input().split()))) for _ in range(3)]
n = int(input())
b = [int(input())for _ in range(n)]
for i in b:
  for j in range(3):
    for k in range(3):
      if a[j][k] == i:
        a[j][k] = 1
ans = 0
count =0
for j in range(3):
  if a[j].count(1) == 3:
    ans += 1
  elif (a[0][j] == a[1][j] == a[2][j]) == 1:
    ans += 1
  elif (a[j][j] == a[j][j] == a[j][j]) == 1:
    ans += 1
  elif (a[0][2] == a[1][1] == a[2][1]) == 1:
    ans += 1
if ans > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a = []
[a.append(list(map(int, input().split()))) for _ in range(3)]
n = int(input())
b = [int(input())for _ in range(n)]
card_check = [[0] * 3] * 3 
for i in b:
  for j in range(3):
    for k in range(3):
      if a[j][k] == i:
        card_check[j][k] = 1

for j in range(3):
  if card_check[j].count(1) == 3:
    print("Yes")
    exit()
  count = 0
  diagonally1 = 0
  diagonally2 = 0
  for k in range(3):
    if card_check[j][k] == 1:
      count += 1
    elif j + k == 4:
      diagonally1 += 1
    elif j == k and card_check[j][k] == 1:
      diagonally2 += 1

  if count == 3 or diagonally1 == 3 or diagonally2 == 3:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
i,j,k,c,z=0,0,0,0,0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]=="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]=="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]=="x":
        c+=1
print(a)
if c!=0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
c=0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]=="x":
    c+=1

if a[0][2]==a[1][1]==a[2][0]=="x":
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]=="x":
        c+=1

if c!=0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

sheet=[input().split() for l in range(3)]
n=int(input())
b=[input() for i in range(n)]
a=np.array(sheet)
c=0

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]="x"


if a[0][0]==a[1][1]==a[2][2]:
    c+=1

if a[0][2]==a[1][1]==a[2][0]:
    c+=1

for z in range(3):
    if a[0][z]==a[1][z]==a[2][z]:
        c+=1

if c!=0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def check_line(start, dxy):
    x, y = start
    dx, dy = dxy
    flg = bingo[x][y]
    for _ in range(2):
        x += dx
        y += dy
        flg &= bingo[x][y]
    return flg

Alist = [list(map(int, input().split())) for _ in range(3)]
Aset = set()
for line in Alist:
    Aset |= set(line)
bingo = [[False] * 3 for i in range(3)]
N = int(input())
br = False
for _ in range(N):
    b = int(input())
    if b in Aset:
        for x in range(3):
            if br:
                br = False
                break
            for y in range(3):
                if Alist[x][y] == b:
                    bingo[x][y] = True
                    br = True
                    break

ans = False
for i in range(3):
    ans |= check_line((0, i), (1, 0))
    ans |= check_line((i, 0), (0, 1))
ans |= check_line((0, 0), (1, 1))
ans |= check_line((0, 2), (1, -1))
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
data = []
for j in range(3):
  data.extend([int (i) for i in input().split()])

bingo_dic = {}
for i, d in enumerate(data):
  bingo_dic[d] = i
  
N = int(input())

bingo = [0,0,0,0,0,0,0,0,0]
for _ in range(N):
  i = int(input())
  if i in bingo_dic.keys():
    bingo[bingo_dic[i]] = 1
    
if bingo[0] + bingo[1] + bingo[2] == 3:
  print('yes')
  exit()
  
if bingo[3] + bingo[4] + bingo[5] == 3:
  print('yes')
  exit()
  
if bingo[6] + bingo[7] + bingo[8] == 3:
  print('yes')
  exit()
  
if bingo[0] + bingo[3] + bingo[6] == 3:
  print('yes')
  exit()

if bingo[1] + bingo[4] + bingo[7] == 3:
  print('yes')
  exit()
  
if bingo[2] + bingo[5] + bingo[8] == 3:
  print('yes')
  exit()
  
if bingo[0] + bingo[4] + bingo[8] == 3:
  print('yes')
  exit()

if bingo[2] + bingo[4] + bingo[6] == 3:
  print('yes')
  exit()

print('no')

Submission status: Wrong Answer

Solution code:

data = []
for j in range(3):
  data.extend([int (i) for i in input().split()])

bingo_dic = {}
for i, d in enumerate(data):
  bingo_dic[d] = i
  
N = int(input())

bingo = [0,0,0,0,0,0,0,0,0]
for _ in range(N):
  i = int(input())
  if i in bingo_dic.keys():
    bingo[bingo_dic[i]] = 1
    
if bingo[0] + bingo[1] + bingo[2] == 3:
  print('yes')
  exit()
  
if bingo[3] + bingo[4] + bingo[5] == 3:
  print('yes')
  exit()
  
if bingo[6] + bingo[7] + bingo[8] == 3:
  print('yes')
  exit()
  
if bingo[0] + bingo[3] + bingo[6] == 3:
  print('yes')
  exit()

if bingo[1] + bingo[4] + bingo[7] == 3:
  print('yes')
  exit()
  
if bingo[2] + bingo[5] + bingo[8] == 3:
  print('yes')
  exit()
  
if bingo[0] + bingo[4] + bingo[8] == 3:
  print('yes')
  exit()

if bingo[2] + bingo[4] + bingo[6] == 3:
  print('yes')
  exit()

print('no')

Submission status: Wrong Answer

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))

N = int(input())
for i in range(N):
    b = int(input())
    if A_1[0] == b:
        A_1[0] = 0
    if A_1[1] == b:
        A_1[1] = 0
    if A_1[2] == b:
        A_1[1] = 0
    if A_2[0] == b:
        A_2[0] = 0
    if A_2[1] == b:
        A_2[1] = 0
    if A_2[2] == b:
        A_2[2] = 0
    if A_3[0] == b:
        A_3[0] = 0
    if A_3[1] == b:
        A_3[1] = 0
    if A_3[2] == b:
        A_3[2] = 0
if A_1 == [0, 0, 0] or A_2 == [0, 0, 0] or A_3 == [0, 0, 0]:
    print("Yes")
    exit()
for j in range(3):
     if A_1[j] == 0 and A_2[j] == 0 and A_3[j] == 0:
         print("Yes")
         exit()
if A_1[0] == 0 and A_2[1] == 0 and A_3[2] == 0:
    print("Yes")
    exit()

if A_3[0] == 0 and A_2[1] == 0 and A_1[2] == 0:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
def main():
    bingo = [[int(e) for e in input().split(" ")] for _ in range(3)]
    card = [[False, False, False], [False, False, False], [False, False, False,]]
    n = int(input())
    for _ in range(n):
        b = int(input())
        r = search(bingo, b)
        if(r != None):
            card[r[0]][r[1]] = True
    print(check(card))

def search(bingo, b):
    for i in range(3):
        for j, x in enumerate(bingo[i]):
            if x == b:
                return (i, j)
    else:
        return None

def check(card):
    result = []
    for e in card:
        if(e[0] and e[1] and e[2]):
            return "Yes"
    else:
        if(
            (card[0][0] and card[1][1] and card[2][2])
            or (card[2][0] and card[1][1] and card[0][2])):
            return "Yes"
        else:
            return "No"

main()

Submission status: Wrong Answer

Solution code:
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))

for j in range(int(input())):
    X=int(input())
    for i in range(3):
        if X in a1:
            num=a1.index(X)
            a1[num]=[0]
        
        elif X in a2:
            num=a2.index(X)
            a2[num]=[0]
            
        elif X in a3:
            num=a3.index(X)
            a3[num]=[0]
        
        
        
C=False
for i in range(3):
    if a1.count(0)==3 or a2.count(0)==3 or a3.count(0)==3 or a1[0]==a2[0]==a3[0]==[0] or a1[1]==a2[1]==a3[1]==[0] or a1[2]==a2[2]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[2]==a2[1]==a3[0]==[0]:
        C=True

if C==True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))

for j in range(int(input())):
    X=int(input())
    for i in range(3):
        if X in a1:
            num=a1.index(X)
            a1[num]=[0]
        
        if X in a2:
            num=a2.index(X)
            a2[num]=[0]
            
        if X in a3:
            num=a3.index(X)
            a3[num]=[0]
        
        
        
C=False
for i in range(3):
    if a1.count(0)==3 or a2.count(0)==3 or a3.count(0)==3 or a1[0]==a2[0]==a3[0]==[0] or a1[1]==a2[1]==a3[1]==[0] or a1[2]==a2[2]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[2]==a2[1]==a3[0]==[0]:
        C=True

if C==True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
array= []
for i in range(3):
    array.append(list(map(int,input().split())))
n= int(input())
number=[]
answer = "No"
for i in range(n):
    number.append(input())

for i in range (3):
    for j in range(3):
        for k in range(n):
            print(array[i][j])
            print(number[k])
            if int(array[i][j]) == int(number[k]):
                array[i][j] = 8101919

for i in range (3):
    if array[i][0] & array[i][1] & array[i][2] == 8101919:        
        answer = "Yes"

for i in range(3):
    if array[0][i] & array[1][i] & array[2][i] == 8101919:
        answer = "Yes"

if array[0][0] & array[1][1] & array[2][2] == 8101919:
    answer = "Yes"
           
if array[2][0] & array[1][1] & array [0][2] == 8101919:
    answer = "Yes"

print(answer)

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if a[i][j] == b:
            a[i][j] = 1

ans = 'No'

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 1:
        print('Yes')
    elif a[0][i] == a[1][i] == a[2][i] == 1:
        print('Yes')
if a[0][0] == a[1][1] == a[2][2] == 1:
        print('Yes')
if a[2][0] == a[1][1] == a[0][2] == 1:
        print('Yes')
print(ans)

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if a[i][j] == b:
            a[i][j] = 1

ans = 'No'

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 1:
        ans = 'Yes'
    elif a[0][i] == a[1][i] == a[2][i] == 1:
        ans = 'Yes'
if a[0][0] == a[1][1] == a[2][2] == 1:
        ans = 'Yes'
if a[2][0] == a[1][1] == a[0][2] == 1:
        ans = 'Yes'
print(ans)

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if a[i][j] == b:
            a[i][j] = 1

ans = 'No'

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2]:
        ans = 'Yes'
    elif a[0][i] == a[1][i] == a[2][i]:
        ans = 'Yes'
if a[0][0] == a[1][1] == a[2][2]:
        ans = 'Yes'
if a[2][0] == a[1][1] == a[0][2]:
        ans = 'Yes'
print(ans)

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if a[i][j] == b:
            a[i][j] = 1

ans = 'No'

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2]:
        ans = 'Yes'
    elif a[0][i] == a[1][i] == a[2][i]:
        ans = 'Yes'
    elif a[0][0] == a[1][1] == a[2][2]:
        ans = 'Yes'
    elif a[2][0] == a[1][1] == a[0][2]:
        ans = 'Yes'
print(ans)