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: Accepted

Solution code:
lsa=list(map(int,input().split()))
lsb=list(map(int,input().split()))
lsc=list(map(int,input().split()))
n=int(input())
called=[int(input()) for i in range(n)]

lsaa=[lsa[0],lsb[0],lsc[0]]
lsbb=[lsa[1],lsb[1],lsc[1]]
lscc=[lsa[2],lsb[2],lsc[2]]

lsx=[lsa[0],lsb[1],lsc[2]]
lsy=[lsa[2],lsb[1],lsc[0]]

ls=[lsa,lsb,lsc,lsaa,lsbb,lscc,lsx,lsy]

for i in ls:
    flag=False
    for j in i:
        if j in called:
            flag=True
        else:
            flag=False
            break
    if flag:
        break

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

Submission status: Accepted

Solution code:
As = []
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))

cs = [[0,0,0], [0,0,0],[0,0,0]]
pos_dic = {}
for i,x in enumerate(As):
  for j,xx in enumerate(x):
    pos_dic[xx] = (i,j)
    
def check(cs):
  for i in range(3):
    if sum(cs[i]) == 3:
      return True
    if (cs[0][i] + cs[1][i] + cs[2][i]) == 3:
      return True
  if (cs[2][2] + cs[1][1] + cs[0][0]) == 3:
    return True
  if (cs[2][0] + cs[1][1] + cs[0][2]) == 3:
    return True
  return False
    

flag = 0
N = int(input())
for i in range(N):
  x = int(input())
  if x in pos_dic:
    i,j = pos_dic[x]
    cs[i][j] = 1
    if check(cs):
      flag = 1
      break
if flag == 0:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
bingo = []
for i in range(3):
    arr = list(map(int, input().split()))
    bingo.append(arr)
n = int(input())
for i in range(n):
    cursor = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == cursor:
                bingo[j][k] = 0
flag = False
for i in bingo:
    if sum(i) == 0:
        flag = True
for i in range(3):
    if bingo[0][i] + bingo[1][i] + bingo[2][i] == 0:
        flag = True
cross1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
cross2 = bingo[0][2] + bingo[1][1] + bingo[2][0]
if cross1 == 0 or cross2 == 0:
    flag = True

if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
R_1 = list(map(int,input().split()))
R_2 = list(map(int,input().split()))
R_3 = list(map(int,input().split()))

C_1 = [R_1[0],R_2[0],R_3[0]]
C_2 = [R_1[1],R_2[1],R_3[1]]
C_3 = [R_1[2],R_2[2],R_3[2]]

S_R = [R_1[2],R_2[1],R_3[0]]
S_L = [R_1[0],R_2[1],R_3[2]]

n = int(input())
for i in range(n):
    tmp = int(input())
    R_1 = [j for j in R_1 if j != tmp]
    R_2 = [j for j in R_2 if j != tmp]
    R_3 = [j for j in R_3 if j != tmp]
    C_1 = [j for j in C_1 if j != tmp]
    C_2 = [j for j in C_2 if j != tmp]
    C_3 = [j for j in C_3 if j != tmp]
    S_R = [j for j in S_R if j != tmp]
    S_L = [j for j in S_L if j != tmp]

if len(R_1)*len(R_2)*len(R_3)*len(C_1)*len(C_2)*len(C_3)*len(S_R)*len(S_L) == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

num_array = np.ones((3, 3), int)
for row in range(3):
    num_array[row, :] = list(map(int, input().split()))

n = int(input())
b_list = [int(input()) for i in range(n)]

b_set = set(b_list)
flag = False

for i in range(3):
    tate = set(num_array[i, :])
    yoko = set(num_array[:, i])
    if len(tate & b_set) == 3 or len(yoko & b_set) == 3:
        flag = True 

naname_one = set([num_array[0,0], num_array[1,1], num_array[2,2]])
naname_two = set([num_array[0,2], num_array[1,1], num_array[2,0]])
if len(naname_one & b_set) == 3 or len(naname_two & b_set) == 3:
    flag = True

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

Submission status: Accepted

Solution code:

A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))

A=[]
A.append(A1)
A.append(A2)
A.append(A3)
N=int(input())

ans='No'

for _ in range(N):
    b=int(input())
    if b in A1:
        A1[A1.index(b)]=0
    if b in A2:
        A2[A2.index(b)]=0
    if b in A3:
        A3[A3.index(b)]=0

if not any(A1) or not any(A2) or not any(A3) :#全てFalse
    ans='Yes'

A1c=[A1[0],A2[0],A3[0]]
A2c=[A1[1],A2[1],A3[1]]
A3c=[A1[2],A2[2],A3[2]]

if not any(A1c) or not any(A2c) or not any(A3c) :#全てFalse
    ans='Yes'

A1n=[A1[0],A2[1],A3[2]]
A2n=[A1[2],A2[1],A3[0]]

if not any(A1n) or not any(A2n):#全てFalse
    ans='Yes'

print(ans)

Submission status: Accepted

Solution code:
from itertools import product

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
bingo = [[0] * 3 for _ in range(3)]
for b in B:
    for i, j in product(range(3), repeat=2):
        if A[i][j] == b:
            bingo[i][j] = 1
            break
flag = False
for i in range(3):
    if sum(bingo[i][j] for j in range(3)) == 3:
        flag = True
for j in range(3):
    if sum(bingo[i][j] for i in range(3)) == 3:
        flag = True
if sum(bingo[i][i] for i in range(3)) == 3 or sum(bingo[i][2-i] for i in range(3)) == 3:
    flag = True
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
*A1, = map(int, input().split())
*A2, = map(int, input().split())
*A3, = map(int, input().split())
A = A1 + A2 + A3
N = int(input())
a = [int(input()) for _ in range(N)]
chk = [A[:3], A[3:6], A[6:9], A[::3], A[1::3], A[2::3], A[::4], A[2:7:2]]
for c in chk:
    ans = 0
    for cc in c:
        if cc in a:
            ans += 1
    if ans == 3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''

#def sol(n,):    
    
def main():
    import sys
    input = sys.stdin.readline
    
    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.append(int(input()))
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if B[i]==A[j][k]:
                    A[j][k]=101
    flg = False
    for i in range(3):
        if A[i][0] == A[i][1]== A[i][2]==101:
            flg = True
            break
    for j in range(3):
        if A[1][j] == A[2][j] == A[0][j]==101:
            flg = True
            break
    if A[0][0] == A[1][1] == A[2][2] == 101 or A[0][2] == A[1][1] == A[2][0] == 101:
        flg = True
    if flg:
        print("Yes")
    else:
        print("No")



    



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    from sys import stdin
    f_i = stdin
    
    A = []
    for i in range(3):
        A += list(map(int, f_i.readline().split()))
    
    nums = dict()
    for a in A:
        nums[a] = True
    
    N = int(f_i.readline())
    
    for i in range(N):
        b = int(f_i.readline())
        if b in nums:
            nums[b] = False
    
    line = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7),
            (2, 5, 8), (0, 4, 8), (2, 4, 6)]
    
    for l in line:
        for n in l:
            if nums[A[n]]:
                break
        else:
            ans = 'Yes'
            break
    else:
        ans = 'No'
    
    print(ans)

solve()

Submission status: Accepted

Solution code:
def Yes():
    print("Yes")
    exit()

A1 = list(map(int, input().split(" ")))
A2 = list(map(int, input().split(" ")))
A3 = list(map(int, input().split(" ")))

a1 = [False,False,False]
a2 = [False,False,False]
a3 = [False,False,False]

N  = int(input())

for i in range(0,N):
    b = int(input())
    
    for j in range(0,3):
        if A1[j] == b:
            a1[j] = True
                
    for j in range(0,3):
        if A2[j] == b:
            a2[j] = True
                
    for j in range(0,3):
        if A3[j] == b:
            a3[j] = True  

# print(a1)
# print(a2)
# print(a3)

if sum(a1) == 3 or sum(a2) == 3 or sum(a3) == 3:
    Yes()
    
for n in range(0,3):
    if a1[n] == True and a2[n]== True and a3[n] == True:
        Yes()

if (a1[0] == True and a2[1] == True and a3[2] == True) or (a3[0] == True and a2[1] == True and a1[2] == True):
    Yes()
    
print("No")

Submission status: Accepted

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


card = [[False for _ in range(3)] for _ in range(3)]

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

bingo = False
for i in range(3):
    if (card[i][0] and card[i][1] and card[i][2]) or (card[0][i] and card[1][i] and card[2][i]):
        bingo = True
        break
if (card[0][2] and card[1][1] and card[2][0]) or (card[0][0] and card[1][1] and card[2][2]):
    bingo = True

ans = "Yes" if bingo else "No"
print(ans)

Submission status: Accepted

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

A = list()
A.extend(A_1)
A.extend(A_2)
A.extend(A_3)

card = [0]*9

for _ in range(N):
    b_i = int(input())
    for i in range(9):
        if b_i == A[i]:
            card[i] = 1


bingo = list()
bingo.append(card[0]+card[1]+card[2])
bingo.append(card[3]+card[4]+card[5])
bingo.append(card[6]+card[7]+card[8])

bingo.append(card[0]+card[3]+card[6])
bingo.append(card[1]+card[4]+card[7])
bingo.append(card[2]+card[5]+card[8])

bingo.append(card[0]+card[4]+card[8])
bingo.append(card[2]+card[4]+card[6])

get_bingo = 0
for i in range(8):
    if bingo[i] == 3:
        get_bingo += 1

if get_bingo == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

for i in range(N):
  for m in range(3):
    for n in range(3):
      if A[m][n] == b[i]:
        A[m][n] = 1
        
for m in range(3):
  if A[m][0] == A[m][1] and A[m][1] == A[m][2] and A[m][0] == A[m][2]:
    flag = 1
    
for n in range(3):
  if A[0][n] == A[1][n] and A[1][n] == A[2][n] and A[0][n] == A[2][n]:
    flag = 1
    
if A[0][0] == A[1][1] and A[1][1] == A[2][2] and A[0][0] == A[2][2]:
  flag = 1
  
if A[0][2] == A[1][1] and A[1][1] == A[2][0] and A[0][2] == A[2][0]:
  flag = 1
  
if flag == 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
matrix = []

for i in range(0,3):
  matrix.append( list(map(int,input().split())) )
  
num = int(input())
num_list = []

for i in range(0,num):
  num_list.append(int(input()))
  
for i in range(0,3):
  for j in range(0,3):
    if matrix[i][j] in num_list :
      matrix[i][j] = 1
    elif matrix[i][j] not in num_list:
      matrix[i][j] = 0
  
sign = []
sign.append(matrix[0][0]*matrix[0][1]*matrix[0][2])
sign.append(matrix[1][0]*matrix[1][1]*matrix[1][2])
sign.append(matrix[2][0]*matrix[2][1]*matrix[2][2])
sign.append(matrix[0][0]*matrix[1][0]*matrix[2][0])
sign.append(matrix[0][1]*matrix[1][1]*matrix[2][1])
sign.append(matrix[0][2]*matrix[1][2]*matrix[2][2])
sign.append(matrix[0][0]*matrix[1][1]*matrix[2][2])
sign.append(matrix[2][0]*matrix[1][1]*matrix[2][0])

if 1 in sign:
  ans = "Yes"
else:
  ans = "No"
  
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

A = np.array([list(map(int, input().split())) for _ in range(3)])
N = int(input())
B = [[False for j in range(3)] for i in range(3)]
for i in range(N):
    b = int(input())
    idx = np.where(A == b)
    # print(idx)
    try:
        x, y = int(idx[0]), int(idx[1])
        B[x][y] = True
    except:
        pass

flag = False

for i in range(3):
    if B[i][0] and B[i][1] and B[i][2]:
        flag = True
    if B[0][i] and B[1][i] and B[2][i]:
        flag = True
if B[0][0] and B[1][1] and B[2][2]:
    flag = True
if B[2][0] and B[1][1] and B[0][2]:
    flag = True
print("Yes" if flag else "No")

Submission status: Accepted

Solution code:
def check_bingo(point_list):
  BINGO_LIST = (
    ((0, 0), (0, 1), (0, 2)),
    ((1, 0), (1, 1), (1, 2)),
    ((2, 0), (2, 1), (2, 2)),
    ((0, 0), (1, 0), (2, 0)),
    ((0, 1), (1, 1), (2, 1)),
    ((0, 2), (1, 2), (2, 2)),
    ((0, 0), (1, 1), (2, 2)),
    ((0, 2), (1, 1), (2, 0))
  )
  for bingo_line in BINGO_LIST:
    bingo_flg = True
    for point in bingo_line:
      if point in point_list:
        continue
      else:
        bingo_flg = False
        break
    if bingo_flg:
      return True
  return False

def get_point(ind):
  x = ind % 3
  y = ind // 3
  
  return x, y

number_list = []
point_list = []
for i in range(3):
  number_list.extend(list(map(int, input().split())))
n = int(input())
for i in range(n):
  b = int(input())
  
  if b in number_list:
    point_list.append(get_point(number_list.index(b)))

if check_bingo(point_list):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
bingo = [[0]*3]*3

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

N = int(input())

for i in range(N):
  a = int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == a:
        bingo[j][k] = 200

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

Submission status: Accepted

Solution code:
card = []
# card.append([int(i) for i in input().split()])
# card.append([int(i) for i in input().split()])
# card.append([int(i) for i in input().split()])
# カードの数値は順番にしておいて、あとから四角くする
card.extend([int(i) for i in input().split()])
card.extend([int(i) for i in input().split()])
card.extend([int(i) for i in input().split()])

N = int(input())
hits = []
for i in range(N) :
    h = int(input())
    if (h in card) :
        idx = card.index(h)
        card[idx] = "o"
    # hits.append(int(input()))

# print(card)

# もう愚直に
is_bingo = False
# 横の調査
if (card[0] == "o" and card[1] == "o" and card[2] == "o") :
    is_bingo = True
if (card[3] == "o" and card[4] == "o" and card[5] == "o") :
    is_bingo = True
if (card[6] == "o" and card[7] == "o" and card[8] == "o") :
    is_bingo = True

# 縦の調査
if (card[0] == "o" and card[3] == "o" and card[6] == "o") :
    is_bingo = True
if (card[1] == "o" and card[4] == "o" and card[7] == "o") :
    is_bingo = True
if (card[2] == "o" and card[5] == "o" and card[8] == "o") :
    is_bingo = True

# ななめ
if (card[0] == "o" and card[4] == "o" and card[8] == "o") :
    is_bingo = True
if (card[2] == "o" and card[4] == "o" and card[6] == "o") :
    is_bingo = True

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

Submission status: Accepted

Solution code:
L1=list(map(int,input().split()))
L2=list(map(int,input().split()))
L3=list(map(int,input().split()))
L=L1+L2+L3
ansL=[0]*9

n=int(input())

for i in range(n):
    p=int(input())
    if p in L:
        tmp=L.index(p)
        ansL[tmp]=1


if ansL[0]+ansL[1]+ansL[2]==3 or ansL[3]+ansL[4]+ansL[5]==3 or ansL[6]+ansL[7]+ansL[8]==3 or ansL[0]+ansL[3]+ansL[6]==3 or ansL[1]+ansL[4]+ansL[7]==3 or ansL[2]+ansL[5]+ansL[8]==3 or ansL[0]+ansL[4]+ansL[8]==3 or ansL[2]+ansL[4]+ansL[6]==3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
combinations = [(1, 2, 3), (4, 5, 6), (7, 8, 9),
                (1, 4, 7), (2, 5, 8), (3, 6, 9),
                (1, 5, 9), (5, 5, 7)
                ]

def main():
    a9 = []
    for _ in range(3):
        temp = list(map(int, input().split()))
        a9 += temp

    n = int(input())
    bbb = []
    for _ in range(n):
        b = int(input())
        bbb.append(b)
        if b in a9:
            idx = a9.index(b)
            a9[idx] = 0

    ans = 'No'
    for ccc in combinations:
        bingo_flag = True
        for c in ccc:
            idx = c - 1
            if a9[idx] == 0:
                continue
            else:
                bingo_flag = False
        if bingo_flag:
            ans = 'Yes'
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

tf = [[False for _ in range(3)] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            tf[i][j] = True
ans = "No"
for i in range(3):
    total = 0
    for j in range(3):
        if tf[i][j]:
            total += 1
    if total == 3:
        ans = "Yes"
for i in range(3):
    total = 0
    for j in range(3):
        if tf[j][i]:
            total += 1
    if total == 3:
        ans = "Yes"
if tf[0][0] == tf[1][1] == tf[2][2] == True:
    ans = "Yes"
if tf[2][0] == tf[1][1] == tf[0][2] == True:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
A1 = input().split()
A1 = [int(l) for l in A1]
A2 = input().split()
A2 = [int(l) for l in A2]
A3 = input().split()
A3 = [int(l) for l in A3]

N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        if A1[j] == b:
            A1[j] = 0
    for j in range(3):
        if A2[j] == b:
            A2[j] = 0
    for j in range(3):
        if A3[j] == b:
            A3[j] = 0
T = "No"
if A1[0] == 0 and A1[1] == 0 and A1[2] == 0:
    T = "Yes"
elif A2[0] == 0 and A2[1] == 0 and A2[2] == 0:
    T = "Yes"
elif A3[0] == 0 and A3[1] == 0 and A3[2] == 0:
    T = "Yes"
elif A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
    T = "Yes"
elif A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
    T = "Yes"
for i in range(3):
    if A1[i] == 0 and A2[i] == 0 and A3[i] == 0:
        T = "Yes"
print(T)

Submission status: Accepted

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

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

if sum(c[0])==3 or sum(c[1])==3 or sum(c[2])==3:
    print('Yes')

elif sum(list(map(lambda x: x[0], c)))==3 or sum(list(map(lambda x: x[1], c)))==3 or sum(list(map(lambda x: x[2], c)))==3:
    print('Yes')

elif (c[0][0]==1 and c[1][1]==1 and c[2][2]==1) or (c[0][2]==1 and c[1][1]==1 and c[2][0]==1):
    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
A = [[0] * 3 for i in range(3)]
for i in range(3):
  A[i][0], A[i][1], A[i][2] = map(int, input().split())

n = int(input())
S = []
for _ in range(n):
  S.append(int(input()))
  
for i in range(3):
  for j in range(3):
    if A[i][j] in S:
      A[i][j] = 0
  
ans = False
for i in range(3):
  if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
    ans = True
  if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
    ans = True
    
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
  ans = True
if A[0][2] == 0 and A[1][1] == 0 and A[0][2] == 0:
  ans = True
  
if ans:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a11,a12,a13=map(int, input().split())
a21,a22,a23=map(int, input().split())
a31,a32,a33=map(int, input().split())
a=[]
for i in [a11,a12,a13,a21,a22,a23,a31,a32,a33]:
    a.append(i)
    
ans="No"
b=[]
n=int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 0

for i in range(3):
    if a[i]==a[i+3] and a[i+3] ==a[i+6]:
        ans="Yes"

for i in range(3):
    if a[3*i] == a[3*i+1] and a[3*i+1] == a[3*i+2]:
        ans="Yes"

if a[0]==a[4] and a[4]==a[8]:
    ans="Yes"
elif a[2]==a[4] and a[4]==a[6]:
    ans="Yes"

print(ans)

Submission status: Accepted

Solution code:
a = []
for i in range(3):
    a += list((map(int, input().split())))
card = [False] * 9
n = int(input())
# b = []
for i in range(n):
    # b.append(int(input()))
    try:
        card[a.index(int(input()))] = True
    except ValueError:
        continue
if (sum(card[:3]) == 3 or sum(card[3:6]) == 3 or sum(card[6:]) == 3
        or sum(card[::3]) == 3 or sum(card[1::3]) == 3 or sum(card[2::3]) == 3
        or sum(card[::4]) == 3 or sum(card[2:7:2]) == 3):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
A1 = [int(x) for x in stdin.readline().rstrip().split()]
A2 = [int(x) for x in stdin.readline().rstrip().split()]
A3 = [int(x) for x in stdin.readline().rstrip().split()]
A = [A1,A2,A3]
N = int(stdin.readline().rstrip())
B = []
for i in range(N):
    b = int(stdin.readline().rstrip())
    B.append(b)
    
ans = [[False,False,False] for i in range(3)]

for x,j in enumerate(A):
    for y,k in enumerate(j):
        if k in B:
            ans[x][y] = True

f = False
if ans[0][0] and ans[1][1] and ans[2][2]:
    f = True

if ans[0][2] and ans[1][1] and ans[2][0]:
    f = True

ans = np.array(ans)
for m in range(3):
    if all(list(ans[m])):
        f = True
        
    if all (list(ans[:,m])):
        f = True
        
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
data = [0] * 9
for i in b:
    if i in a1:
        data[a1.index(i)] = 1
    if i in a2:
        data[a2.index(i)+3] = 1
    if i in a3:
        data[a3.index(i)+6] = 1

if data[0:3] == [1, 1, 1]:
    print('Yes')
elif data[3:6] == [1, 1, 1]:
    print('Yes')
elif data[6:9] == [1, 1, 1]:
    print('Yes')
elif data[0::3] == [1, 1, 1]:
    print('Yes')
elif data[1::3] == [1, 1, 1]:
    print('Yes')
elif data[2::3] == [1, 1, 1]:
    print('Yes')
elif [data[0], data[4], data[8]] == [1, 1, 1]:
    print('Yes')
elif [data[2], data[4], data[6]] == [1, 1, 1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
card=[list(map(int,input().split())) for i in range(3)]
n=int(input())
at=[[False for i in range(3)] for j in range(3)]
for i in range(n):
    num=int(input())
    for j in range(3):
        for h in range(3):
            if num==card[j][h]:at[j][h]=True
for i in range(3):
    if False not in at[i]:print('Yes');exit()
for j in range(3):
    if False not in (at[0][j],at[1][j],at[2][j]):print('Yes');exit()
if False not in (at[0][0],at[1][1],at[2][2]) or False not in (at[0][2],at[1][1],at[2][0]):print("Yes");exit()
print("No")

Submission status: Accepted

Solution code:
a11,a12,a13=map(int,input().split())
a21,a22,a23=map(int,input().split())
a31,a32,a33=map(int,input().split())
A=[a11,a12,a13,a21,a22,a23,a31,a32,a33]
n=int(input())
b=[]
for i in range(n):
  b.append(int(input()))
for i in range(n):
  for j in range(9):
    if b[i]==A[j]:
      A[j]=0
if A[0]==A[1] and A[1]==A[2] or A[3]==A[4] and A[3]==A[5] or A[6]==A[7] and A[6]==A[8] or A[0]==A[3] and A[0]==A[6] or A[1]==A[4] and A[1]==A[7] or A[2]==A[5] and A[2]==A[8] or A[0]==A[4] and A[0]==A[8] or A[2]==A[4] and A[2]==A[6]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:

field = []
for i in range(3):
    field += list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
hit = [0 for i in range(9)]
for i in b:
    if i in field:
        #hit.append(field.index(i))
        hit[field.index(i)] += 1

if hit[0] == hit[1] == hit[2] == 1:
    print('Yes')
elif hit[3] == hit[4] == hit[5] == 1:
    print('Yes')
elif hit[6] == hit[7] == hit[8] == 1:
    print('Yes')
elif hit[0] == hit[3] == hit[6] == 1:
    print('Yes')
elif hit[1] == hit[4] == hit[7] == 1:
    print('Yes')
elif hit[2] == hit[5] == hit[8] == 1:
    print('Yes')
elif hit[0] == hit[4] == hit[8] == 1:
    print('Yes')
elif hit[2] == hit[4] == hit[6] == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = []

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

n = int(input())

b = []
for _ in range(n):
    b.append(int(input()))

patterns = (
    [[a[i][i] for i in range(3)], [a[2 - i][i] for i in range(3)]]
    + [[a[0][i], a[1][i], a[2][i]] for i in range(3)]
    + [[a[i][0], a[i][1], a[i][2]] for i in range(3)]
)

answer = "No"
for a0, a1, a2 in patterns:
    if a0 in b and a1 in b and a2 in b:
        answer = "Yes"
        break

print(answer)

Submission status: Accepted

Solution code:
s = list(map(int, input().split()))
bingo=[]
bingo+=s
s = list(map(int, input().split()))
bingo += s
s = list(map(int, input().split()))
bingo += s
s = list(map(int, input().split()))
n=s[0]
for i in range(n):
    s = list(map(int, input().split()))
    bingo=[ 0 if j==s[0] else j for j in bingo]
if bingo[0]==bingo[1]==bingo[2]:print('Yes')
elif bingo[0] == bingo[1] == bingo[2]:print('Yes')
elif bingo[3] == bingo[4] == bingo[5]:print('Yes')
elif bingo[6] == bingo[7] == bingo[8]:print('Yes')
elif bingo[0] == bingo[3] == bingo[6]:print('Yes')
elif bingo[1] == bingo[4] == bingo[7]:print('Yes')
elif bingo[2] == bingo[5] == bingo[8]:print('Yes')
elif bingo[0] == bingo[4] == bingo[8]:print('Yes')
elif bingo[2] == bingo[4] == bingo[6]:print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())

B = list(int(input()) for i in range(N))

ans = 0
for a in A1:
  if a in B:
    ans += 1
if ans == 3:
  print('Yes')
else:
  ans = 0
  for a in A2:
    if a in B:
      ans += 1
  if ans==3:
    print('Yes')
  else:
    ans = 0
    for a in A3:
      if a in B:
        ans += 1
    if ans==3:
      print('Yes')  
    else:
      ans = 0
      for a in [A1[0], A2[0], A3[0]]:
        if a in B:
          ans += 1
      if ans==3:
        print('Yes') 
      else:
        ans = 0
        for a in [A1[1], A2[1], A3[1]]:
          if a in B:
            ans += 1
        if ans==3:
          print('Yes')
        else:
          ans = 0
          for a in [A1[2], A2[2], A3[2]]:
            if a in B:
              ans += 1
          if ans==3:
            print('Yes')
          else:
            ans = 0
            for a in [A1[0], A2[1], A3[2]]:
              if a in B:
                ans += 1
            if ans==3:
              print('Yes')
            else:
              ans = 0
              for a in [A1[2], A2[1], A3[0]]:
                if a in B:
                  ans += 1
              if ans==3:
                print('Yes')
              else:
                print('No')

Submission status: Accepted

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


for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==A[j][k]:
                A[j][k]=0

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

Submission status: Accepted

Solution code:

grid = []
for row in range(3):
    row = list(map(int, input().split()))
    grid.append(row)
# print(grid)
n = int(input())

for _ in range(n):
    num = int(input())
    for row in range(3):
        for col in range(3):
            if grid[row][col] == num:
                grid[row][col] = '*'
# print(grid)

# row
is_ok = False
for row in range(3):
    if grid[row][0] == grid[row][1] == grid[row][2] == '*':
        is_ok = True
        break

# col    
for col in range(3):
    if grid[0][col] == grid[1][col] == grid[2][col] == '*':
        is_ok = True
        break


# ななめ
if grid[0][0] == grid[1][1] == grid[2][2] == '*' or grid[0][2] == grid[1][1] == grid[2][0] == '*':    
    is_ok = True

if is_ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = [None] * 3

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

N = int(input())

for n in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

is_bingo = 'No'

for i in range(3):
    if A[i][0] == A[i][1] == A[i][2]:
        is_bingo = 'Yes'

for j in range(3):
    if A[0][j] == A[1][j] == A[2][j]:
        is_bingo = 'Yes'

if A[0][0] == A[1][1] == A[2][2]:
    is_bingo = 'Yes'

if A[0][2] == A[1][1] == A[2][0]:
    is_bingo = 'Yes'

print(is_bingo)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    a=[[0]*3 for _ in range(3)]
    for i in range(3):
        a[i]=list(map(int,input().split()))
    n=int(input())
    b=[0]*n
    for i in range(n):
        b[i]=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                a[i][j]=0
    ans=a[0][0]+a[1][1]+a[2][2]
    ans*=a[0][0]+a[0][1]+a[0][2]
    ans*=a[0][0]+a[1][0]+a[2][0]
    ans*=a[1][0]+a[1][1]+a[1][2]
    ans*=a[0][1]+a[1][1]+a[2][1]
    ans*=a[2][0]+a[2][1]+a[2][2]
    ans*=a[0][2]+a[1][2]+a[2][2]
    ans*=a[0][2]+a[1][1]+a[2][0]
    if ans==0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力
A = []
B = []

for i in range(3):
    a1, a2, a3 = map(int, input().split())
    A.append([a1, a2, a3])

N = int(input())
for i in range(N):
    B.append(int(input()))

def isBingo():
    for i in range(3):
        if set(A[i]) <= set(B):
            return True
        if {A[0][i], A[1][i], A[2][i]} <= set(B):
            return True

    if {A[0][0], A[1][1], A[2][2]} <= set(B):
        return True
    if {A[2][0], A[1][1], A[0][2]} <= set(B):
        return True

    return False


if isBingo():
    print('Yes')
else:
    print('No')