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:
#!/usr/bin/env python3
As = [list(map(int, input().split())) for i in range(3)]
N = int(input())
x = []
bingo = [[False]*3 for i in range(3)]
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if As[i][j] == b:
                bingo[i][j] = True

ans = True
for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2] : 
        print("Yes")
        exit()
for j in range(3):
    if bingo[0][j] and bingo[1][j] and bingo[2][j]:
        print("Yes")
        exit()
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    print("Yes" )
    exit()
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
    print("Yes")
    exit()
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 = [0] * N 
for i in range(N):
    b[i] = int(input())
A = [A1,A2,A3]
B = [[0]*3,[0]*3,[0]*3]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                B[i][j] = 1
if B[0] == [1,1,1]:
    print("Yes")
elif B[1] == [1,1,1]:
    print("Yes")
elif B[2] == [1,1,1]:
    print("Yes")
elif B[0][0] == 1 and B[1][0] == 1 and B[2][0] == 1:
    print("Yes")
elif B[0][1] == 1 and B[1][1] == 1 and B[2][1] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][2] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
## input list ##
n1 = list(map(int,input().split()))
n2 = list(map(int,input().split()))
n3 = list(map(int,input().split()))

nall  = n1 + n2 + n3
#print(nall)

## input iterate num ##
N = int(input())

## input number ##
num = []
for i in range(N):
  add = int(input())
  num.append(add)

#print(num)

## check same number ##
out = []
for i in range(len(nall)):
  if nall[i] in num:
    out.append(i)

##print(out)

## check bingo ##
out_set = set(out)
#print(out_set)

bingo1 = [0,1,2]
bingo2 = [3,4,5]
bingo3 = [6,7,8]
bingo4 = [0,3,6]
bingo5 = [1,4,7]
bingo6 = [2,5,8]
bingo7 = [0,4,8]
bingo8 = [6,4,2]

if (set(bingo1) <= set(out_set)) or (set(bingo2) <= set(out_set)) or (set(bingo3) <= set(out_set)) or (set(bingo4) <= set(out_set)) or (set(bingo5) <= set(out_set)) or (set(bingo6) <= set(out_set)) or (set(bingo7) <= set(out_set)) or (set(bingo8) <= set(out_set)):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
Bingo = [[0,0,0],[0,0,0],[0,0,0]]
Bingo[0][0],Bingo[0][1],Bingo[0][2]= map(int, input().split())  
Bingo[1][0],Bingo[1][1],Bingo[1][2]= map(int, input().split()) 
Bingo[2][0],Bingo[2][1],Bingo[2][2]= map(int, input().split()) 
N = int(input())
Numbers = [int(input() )for _ in range(N)]

#判定用
maru =[[0,0,0],[0,0,0],[0,0,0]]
Flag =0


for Number in Numbers:
  for i in range(3):
    for j in range(3):
      if Bingo[i][j] == Number:
        maru[i][j]=1

for i in range(3):
  if maru[0][i] ==1 and maru[1][i]== 1 and maru[2][i] ==1:
    Flag = 1
    break
    
  if maru[i][0] ==1 and maru[i][1]== 1 and maru[i][2] ==1:
    Flag = 1
    break

  if maru[0][0] ==1 and maru[1][1]== 1 and maru[2][2]==1:
    Flag = 1
    break

  if maru[0][2] ==1 and maru[1][1]== 1 and maru[2][0]==1:
    Flag = 1
    break

if Flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys
list1=[]
list3=["Bingo","Bingo","Bingo"]
A1,A2,A3=map(str,input().split())
A4,A5,A6=map(str,input().split())
A7,A8,A9=map(str,input().split())
n=int(input())
list1=[input() for i in range(1,n+1)]
list2=[[A1,A2,A3],
    [A4,A5,A6],
    [A7,A8,A9]]
for y in range(3):
    for x in range(n):
            if (list1[x] in list2[y])==True:
                s=list2[y].index(list1[x])
                list2[y][s]="Bingo"
#横
for i in range(3):
    if list2[i]==list3:
        print("Yes")
        sys.exit()
#斜め
if list2[0][0]==list2[1][1] and list2[1][1]==list2[2][2]:
    print("Yes")
elif list2[0][2]==list2[1][1] and list2[1][1]==list2[2][0]:
    print("Yes")
#縦
elif list2[0][0]==list2[1][0] and list2[1][0]==list2[2][0]:
    print("Yes")
elif list2[0][1]==list2[1][1] and list2[1][1]==list2[2][1]:
    print("Yes")
elif list2[0][2]==list2[1][2] and list2[1][2]==list2[2][2]:
    print("Yes")
elif n<=2:
    print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
A,B,C = map(int,input().split())
D,E,F = map(int,input().split())
G,H,I = map(int,input().split())
N =int(input())
s = [int(input()) for _ in range(N)]

initial_board = [A,B,C,D,E,F,G,H,I]
called = [0]*9

for i in range(9):
  if initial_board[i] in s:
    called[i] = 1

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

Submission status: Accepted

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

for _ in range(n):
    b = int(input())
    for rows in range(3):
        for columns in range(3):
            if m[rows][columns] == b:
                m[rows][columns] = 0

for i in range(3):
    if sum(m[i]) == 0:
        print('Yes')
        exit()
for i in range(3):
    if m[0][i] + m[1][i] + m[2][i] == 0:
        print('Yes')
        exit()
if m[0][0] + m[1][1] + m[2][2] == 0: print('Yes'); exit()
if m[0][2] + m[1][1] + m[2][0] == 0: print('Yes'); exit()
 
print('No')

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)]
bingo = [[0 for _ in range(3)] for _ in range(3)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                bingo[j][k] = True
if (bingo[0][0] and bingo[1][0] and bingo[2][0]) or (bingo[0][1] and bingo[1][1] and bingo[2][1]) or (bingo[0][2] and bingo[1][2] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[0][1] and bingo[0][2]) or (bingo[1][0] and bingo[1][1] and bingo[1][2]) or (bingo[2][0] and bingo[2][1] and bingo[2][2]):
    print('Yes')
elif (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

    for _ in range(N):
        b = int(input())
        for a_i in range(3):
            for a_j in range(3):
                if A[a_i][a_j] == b:
                    A[a_i][a_j] = "empty"

    ans = "No"
    for i in range(3):
        if A[i][0] == "empty" and A[i][1] == "empty" and A[i][2] == "empty":
            ans = "Yes"
            break

    for j in range(3):
        if A[0][j] == "empty" and A[1][j] == "empty" and A[2][j] == "empty":
            ans = "Yes"
            break

    if A[0][0] == "empty" and A[1][1] == "empty" and A[2][2] == "empty":
        ans = "Yes"

    if A[2][0] == "empty" and A[1][1] == "empty" and A[0][2] == "empty":
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in N_number:
    for j in Bingo_number:
        for k in range(len(Bingo_number)):
            if i[0] == j[k]:
                j[k] = "+"
# print(Bingo_number)

ans = 0
count2 = 0
count3 = 0

for i in range(3):
    count = 0
    count1 = 0
    for j in range(3):
        if Bingo_number[i][j] == "+":
            count += 1
        if Bingo_number[j][i] == "+":
            count1 += 1
        if i == j:
            if Bingo_number[i][j] == "+":
                count2 += 1
        if i + j == 2:
            if Bingo_number[i][j] == "+":
                count3 += 1
        # print(count, count1, count2, count3)
    if count == 3 or count1 == 3 or count2 == 3 or count3 == 3:
        ans += 1

if ans > 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
l = [list(map(int, input().split())) for i in range(3)]
ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N = int(input())

for i in range(N):
    search = int(input())
    f = 0
    for j in range(3):
        for k in range(3):
            if l[j][k] == search:
                f = 1
                ans[j][k] = 1
                break
        if f == 1:
            break

for i in range(3):
    if (ans[i][0] == 1) and (ans[i][1] == 1) and (ans[i][2] == 1):
        print("Yes")
        exit()
for j in range(3):
    if (ans[0][j] == 1) and (ans[1][j] == 1) and (ans[2][j] == 1):
        print("Yes")
        exit()
if ((ans[0][0] == 1) and (ans[1][1] == 1) and (ans[2][2] == 1)):
    print("Yes")
    exit()
if ((ans[0][2] == 1) and (ans[1][1] == 1) and (ans[2][0] == 1)):
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
A = [input().split() for l in range(3)]
N=int(input())
b = [input() for l in range(N)]

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

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[1][1]==A[2][2]==A[0][0]) or (A[0][2]==A[1][1]==A[2][0]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(n):
    x = int(input())
    for h in range(3):
        for w in range(3):

            if m[h][w] == x: m[h][w] = 0


for i in range(3):
    if sum(m[i]) == 0 :print('Yes'); exit()

for i in range(3):
    if m[0][i] + m[1][i] + m[2][i] == 0: print('Yes'); exit()

if m[0][0] + m[1][1] + m[2][2] == 0: print('Yes'); exit()
if m[0][2] + m[1][1] + m[2][0] == 0: print('Yes'); exit()

print('No')

Submission status: Accepted

Solution code:

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

bingo1 = [0, 0, 0]
bingo2 = [0, 0, 0]
bingo3 = [0, 0, 0]

# 穴を開ける工程
for i in range(3):
  for j in range(N):
    if A[i][0] == b[j]:
      bingo1[i] = 1
    if A[i][1] == b[j]:
      bingo2[i] = 1
    if A[i][2] == b[j]:
      bingo3[i] = 1
      

# ビンゴ判定
if bingo1[0] == bingo1[1] == bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == bingo2[1] == bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == bingo3[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[0] == bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == bingo2[1] == bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == bingo2[2] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[2] == bingo2[1] == bingo3[0] == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = [0]*9
A[0], A[1], A[2] = map(int, input().split())
A[3], A[4], A[5] = map(int, input().split())
A[6], A[7], A[8] = map(int, input().split())
N = int(input())
B = [0]*N
for i in range(N):
    B[i] = int(input())
if A[4] in B:
    if A[0] in B and A[8] in B:
        print("Yes")
        exit()
    if A[2] in B and A[6] in B:
        print("Yes")
        exit()
    if A[1] in B and A[7] in B:
        print("Yes")
        exit()
    if A[3] in B and A[5] in B:
        print("Yes")
        exit()
if A[0] in B and A[1] in B and A[2] in B:
    print("Yes")
    exit()
if A[6] in B and A[7] in B and A[8] in B:
    print("Yes")
    exit()
if A[0] in B and A[3] in B and A[6] in B:
    print("Yes")
    exit()
if A[2] in B and A[5] in B and A[8] in B:
    print("Yes")
    exit()

print("No")

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)]
 
if (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[1][0] in b) and (A[1][1] in b) and (A[1][2] in b) or \
    (A[2][0] in b) and (A[2][1] in b) and (A[2][2] in b) or \
    (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[0][0] in b) and (A[1][0] in b) and (A[2][0] in b) or \
    (A[0][1] in b) and (A[1][1] in b) and (A[2][1] in b) or \
    (A[0][2] in b) and (A[1][2] in b) and (A[2][2] in b) or \
    (A[0][0] in b) and (A[1][1] in b) and (A[2][2] in b) or \
    (A[0][2] in b) and (A[1][1] in b) and (A[2][0] in b):
    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 i in range(N):
    b.append(int(input()))

A4 = []
A5 = []
A6 = []
A7 = []
A8 = []

A4.append(A1[0])
A4.append(A2[0])
A4.append(A3[0])

A5.append(A1[1])
A5.append(A2[1])
A5.append(A3[1])

A6.append(A1[2])
A6.append(A2[2])
A6.append(A3[2])

A7.append(A1[0])
A7.append(A2[1])
A7.append(A3[2])

A8.append(A1[2])
A8.append(A2[1])
A8.append(A3[0])

if b.count(A1[0]) + b.count(A1[1]) + b.count(A1[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A2[0]) + b.count(A2[1]) + b.count(A2[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A3[0]) + b.count(A3[1]) + b.count(A3[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A4[0]) + b.count(A4[1]) + b.count(A4[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A5[0]) + b.count(A5[1]) + b.count(A5[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A6[0]) + b.count(A6[1]) + b.count(A6[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A7[0]) + b.count(A7[1]) + b.count(A7[2]) == 3:
    print ("Yes")
    exit (0)
if b.count(A8[0]) + b.count(A8[1]) + b.count(A8[2]) == 3:
    print ("Yes")
    exit (0)

print ("No")

Submission status: Accepted

Solution code:
import numpy as np

# 入力
#Alist = [input().split() for l in range(3)]
A = np.array([list(map(int,input().split())) for l in range(3)])

N = int(input())

b = [int(input()) for i in range(N)]

for bi in b:
    A = np.where(A==bi,0,A)

counter = 0

for i in range(3):
    if sum(A[i,:]) == 0:
        counter = 1

for i in range(3):
    if sum(A[:,i]) == 0:
        counter = 1

if np.trace(A) == 0 or np.trace(A[::-1]) == 0:
    counter = 1

if counter == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def q2():
    A = []
    for i in range(3):
        A.append([int(a) for a in input().split()])

    m = [[0,0,0],[0,0,0],[0,0,0]]

    N = int(input())
    for i in range(N):
        b = int(input())
        for row, a in enumerate(A):
            if b in a:
                found = a.index(b)
                m[row][found] = 1
                break

    if ((m[0][0] == 1 and m[0][1] == 1 and m[0][2] == 1) or
        (m[1][0] == 1 and m[1][1] == 1 and m[1][2] == 1) or
        (m[2][0] == 1 and m[2][1] == 1 and m[2][2] == 1) or
        (m[0][0] == 1 and m[1][0] == 1 and m[2][0] == 1) or
        (m[0][1] == 1 and m[1][1] == 1 and m[2][1] == 1) or
        (m[0][2] == 1 and m[1][2] == 1 and m[2][2] == 1) or
        (m[0][0] == 1 and m[1][1] == 1 and m[2][2] == 1) or
        (m[0][2] == 1 and m[1][1] == 1 and m[2][0] == 1)):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    q2()

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))
x=[]
for i in range(3):
  for j in range(3):
    if A[i][j] in B:
      x.append(A[i][j])
if A[0][0] in x and A[1][0] in x and A[2][0] in x:
  print("Yes")
elif A[0][1] in x and A[1][1] in x and A[2][1] in x:
  print("Yes")
elif A[0][2] in x and A[1][2] in x and A[2][2] in x:
  print("Yes")
elif A[0][0] in x and A[0][1] in x and A[0][2] in x:
  print("Yes")
elif A[1][0] in x and A[1][1] in x and A[1][2] in x:
  print("Yes")
elif A[2][0] in x and A[2][1] in x and A[2][2] in x:
  print("Yes")
elif A[0][0] in x and A[1][1] in x and A[2][2] in x:
  print("Yes")
elif A[0][2] in x and A[1][1] in x and A[2][0] in x:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import numpy as np
A = np.array([input().split() for _ in range(3)],np.int64).reshape(3,3)
N = int(input())
for i in range(N):
    b = int(input())
    A[A==b] = 0
    
if np.any(np.all(A==0,axis=0)) or np.any(np.all(A==0,axis=1)) or A[0][0] == A[1][1] == A[2][2] == 0 or A[2][0] == A[1][1] == A[0][2] == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
card  = []
balls = []

for _ in range(3):
  card.extend(input().split())

n = int(input())

for _ in range(n):
  balls.append(input())

for i in range(9):
  if card[i] in balls:
    card[i] = "open"

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

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    x = int(input())
    for j in range(3):
        if x in a[j]:
            a[j][a[j].index(x)]=0
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0 or a[0][i]==a[1][i]==a[2][i]==0 or a[0][0]==a[1][1]==a[2][2]==0 or a[0][2]==a[1][1]==a[2][0]==0:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input()))
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A=open(0).read().split()
print('YNeos'[all(t-set(map(A.index,A[10:])) for t in({0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}))::2])

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

bingos = []
for _ in range(3):
   bingo = [int(i) for i in input().split()]
   bingos.append(bingo)
  
N = int(input())

for i in range(N):
    n = int(input())
    for y in range(3):
        for x in range(3):
            if bingos[y][x] == n:
                bingos[y][x] = None

y_cnt = [0] * 3
x_cnt = [0] * 3
result = False
for y in range(3):
    for x in range(3):
        if bingos[y][x] is None:
            x_cnt[y] += 1
            y_cnt[x] += 1

if 3 in y_cnt or 3 in x_cnt:
    print('Yes')
elif bingos[0][0] is None and bingos[1][1] is None and bingos[2][2] is None:
    print('Yes')
elif bingos[0][2] is None and bingos[1][1] is None and bingos[2][0] is None:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(n):
    u = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == u:
                bingo[j][k] = 0
b = 0

for l in range(3):
    if (bingo[l][0] == 0) and (bingo[l][1] == 0) and (bingo[l][2] == 0):
        b = 1
for m in range(3):
    if (bingo[0][m] == 0) and (bingo[1][m] == 0) and (bingo[2][m] == 0):
        b = 1
    
if (bingo[0][0] == 0) and (bingo[1][1] == 0) and (bingo[2][2] == 0):
    b = 1

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

Submission status: Accepted

Solution code:
*A,=map(int,input().split())
A=A+list(map(int,input().split()))
A=A+list(map(int,input().split()))
N=int(input())
i=0
B=[0]*N
while i<=N-1:
    B[i]=int(input())
    i+=1

for x in B:
    if x in A:
        A[A.index(x)]=0

if A[0]+A[1]+A[2]==0:
    print('Yes')
elif A[3]+A[4]+A[5]==0:
    print('Yes')
elif A[6]+A[7]+A[8]==0:
    print('Yes')
elif A[0]+A[3]+A[6]==0:
    print('Yes')
elif A[1]+A[4]+A[7]==0:
    print('Yes')
elif A[2]+A[5]+A[8]==0:
    print('Yes')
elif A[0]+A[4]+A[8]==0:
    print('Yes')
elif A[2]+A[4]+A[6]==0:
    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 = [(int(input())) for _ in range(N)]

bingo1 =[0,0,0]
bingo2 =[0,0,0]
bingo3 =[0,0,0]
for i in range(3):
    for j in range(N):
        if A1[i]==b[j]:
            bingo1[i]=1
        elif A2[i]==b[j]:
            bingo2[i]=1
        elif A3[i]==b[j]:
            bingo3[i]=1    


            
if bingo1[0] == bingo1[1] == bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == bingo2[1] == bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == bingo3[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[0] == bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == bingo2[1] == bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == bingo2[2] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[2] == bingo2[1] == bingo3[0] == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

n = int(input())

for i in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b:
                a[x][y] = -1
                break

is_bingo = False
# | line check
for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -1 or a[0][i] == a[1][i] == a[2][i] == -1:
        is_bingo = True

if not is_bingo:
    if a[0][0] == a[1][1] == a[2][2] == -1 or a[2][0] == a[1][1] == a[0][2] == -1:
        is_bingo = True

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

Submission status: Accepted

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

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] = 0

if (a[0][0] == 0 and a[2][2] == 0 and a[1][1] == 0) or (a[0][2] == 0 and a[2][0] == 0 and a[1][1] == 0): #斜めに揃っていたら
  print("Yes")
  x = 1
for i in range(3):
  if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0 and x == 0: #横に揃っていたら
    print("Yes")
    x = 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0 and x == 0: #縦に揃っていたら
    print("Yes")
    x = 1
    break
if x == 0:
  print("No")

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
lst=[a,b,c,d,e,f,g,h,i]
for i in range(int(input())):
  x=int(input())
  for j in range(9):
    if x==lst[j]:
      lst[j]=0
a,b,c,d,e,f,g,h,i=lst
tf=0
for k in [a+b+c,d+e+f,g+h+i,a+d+g,b+e+h,c+f+i,a+e+i,c+e+g]:
  if not k:
    tf=1
    break
if tf:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

a = []
for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[i][j])

  a.append(a_)

for i in range(card_size):
  a_ = []
  for j in range(card_size):
    a_.append(c[j][i])

  a.append(a_)

a_ = []
for i in range(card_size):
  a_.append(c[i][i])

a.append(a_)

a_ = []
for i in range(card_size):
  a_.append(c[i][card_size-i-1])

a.append(a_)

maru = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
]
 
ans = 0
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        for k in range(3):
            if b == a[j][k]:
                maru[j][k] = 1
                if maru[j] == [1, 1, 1]:
                    ans = 1
 
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = [[int(x) for x in input().split()] for i in range(3)]
n = int(input())
B = {int(input()) for i in range(n)}
for i in range(3):
  for j in range(3):
    if A[i][j] in B:
      A[i][j] = 0
flg = False
for i in range(3):
  if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
    flg = True
  if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
    flg = True
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
  flg = True
if A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
  flg = True
print('Yes' if flg else '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],
    [a11, a21, a31],
    [a12, a22, a32],
    [a13, a23, a33],
    [a11, a22, a33],
    [a13, a22, a31],
]

maru = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0],
]

ans = 0
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(8):
        for k in range(3):
            if b == a[j][k]:
                maru[j][k] = 1
                if maru[j] == [1, 1, 1]:
                    ans = 1

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

Submission status: Accepted

Solution code:
A11,A12,A13 = list(map(int, input().split()))
A21,A22,A23 = list(map(int, input().split()))
A31,A32,A33 = list(map(int, input().split()))
l=[[A11,A12,A13],[A21,A22,A23],[A31,A32,A33],[A11,A22,A33],[A13,A22,A31],[A11,A21,A31],[A12,A22,A32],[A13,A23,A33]]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(8):
        if b in l[j]:
            l[j].remove(b)
f=1
for i in range(8):
    if l[i]==[]:
        print('Yes')
        f-=1
        break
if f==1:
    print('No')

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

if (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[1][0] in b) and (A[1][1] in b) and (A[1][2] in b) or \
    (A[2][0] in b) and (A[2][1] in b) and (A[2][2] in b) or \
    (A[0][0] in b) and (A[0][1] in b) and (A[0][2] in b) or \
    (A[0][0] in b) and (A[1][0] in b) and (A[2][0] in b) or \
    (A[0][1] in b) and (A[1][1] in b) and (A[2][1] in b) or \
    (A[0][2] in b) and (A[1][2] in b) and (A[2][2] in b) or \
    (A[0][0] in b) and (A[1][1] in b) and (A[2][2] in b) or \
    (A[0][2] in b) and (A[1][1] in b) and (A[2][0] in b):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

A = []
B = [[False for i in range(3)] for j in range(3)]
l = []
for i in range(3):
    A.append(iil())
    for item in A[i]:
        l.append(item)


n = ii()
for i in range(n):
    call = ii()
    if call in l:
        p = l.index(call)
        B[p//3][p%3] = True

if B[0][0]*B[0][1]*B[0][2] == 1:
    print('Yes')
elif B[1][0]*B[1][1]*B[1][2] == 1:
    print('Yes')
elif B[2][0]*B[2][1]*B[2][2] == 1:
    print('Yes')
elif B[0][0]*B[1][1]*B[2][2] == 1:
    print('Yes')
elif B[0][2]*B[1][1]*B[2][0] == 1:
    print('Yes')
elif B[0][0]*B[1][0]*B[2][0] == 1:
    print('Yes')
elif B[0][1]*B[1][1]*B[2][1] == 1:
    print('Yes')
elif B[0][2]*B[1][2]*B[2][2] == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
k = list(map(int, input().split()))
l = list(map(int, input().split()))
m = list(map(int, input().split()))
n = int(input())
count = 0

# bと等しければ数字を0に変更
for i in range(n):
  b = int(input())
  for j in range(3):
    if k[j] == b:
      k[j] = 0
    elif l[j] == b:
      l[j] = 0
    elif m[j] == b:
      m[j] = 0

# 数字の重複を判定（0以外の重複はない）
if k[0] == k[1] and k[1] == k[2]:
  count += 1
elif l[0] == l[1] and l[1] == l[2]:
  count += 1
elif m[0] == m[1] and m[1] == m[2]:
  count += 1
elif k[0] == l[1] and l[1] == m[2]:
  count += 1
elif k[2] == l[1] and l[1] == m[0]:
  count += 1
else:
  for i in range(3):
    if k[i] == l[i] and l[i] == m[i]:
      count += 1

print("Yes" if count > 0 else "No")

Submission status: Accepted

Solution code:
a=[[0]*3 for i in range(3)]
wk=[[0]*3 for i in range(3)]
a[0]=input().split()
a[1]=input().split()
a[2]=input().split()
n=int(input())
chk=False
for i in range(n):
  chk=False
  b=input()
  for j in range(3):
    if chk:
      break
    for k in range(3):
      if a[j][k]==b:
        wk[j][k]=1
        chk=True
        break
if [wk[0][0],wk[0][1],wk[0][2]]==[1,1,1]:
  print("Yes")
elif [wk[1][0],wk[1][1],wk[1][2]]==[1,1,1]:
  print("Yes")
elif [wk[2][0],wk[2][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][1],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][2],wk[2][2]]==[1,1,1]:
  print("Yes")
elif [wk[0][1],wk[1][1],wk[2][1]]==[1,1,1]:
  print("Yes")
elif [wk[0][0],wk[1][0],wk[2][0]]==[1,1,1]:
  print("Yes")
elif [wk[0][2],wk[1][1],wk[2][0]]==[1,1,1]:
  print("Yes")
else:
  print("No")