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:
#7
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] = -1
bingo = 0

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -1:
        bingo = 1
        
for j in range(3):
    if a[0][j] == a[1][j] == a[2][j] == -1:
        bingo = 1

if a[0][0] == a[1][1] == a[2][2] == -1 or a[0][2] == a[1][1] == a[2][0]:
    bingo = 1

if bingo == 1:
    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
bi =[list(map(int,input().split())) for i in range(3)]
n=int(input())
isok = [[0 for i in range(3)]for j in range(3)]
for i in range(n):
    x = int(input())
    for j in range(3):
        for k in range(3):
            if bi[j][k] == x:
                isok[j][k] = 1

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

Submission status: Accepted

Solution code:
import numpy as np
card = []
for _ in range(3):
    card.append(list(map(int, input().split())))
card = np.array(card)

N = int(input())

B = [int(input()) for _ in range(N)]


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

count_by_row = (card == 0).sum(axis=1)
count_by_col = (card == 0).sum(axis=0)

if (3 in count_by_row) or (3 in count_by_col):
    print("Yes")
elif card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0:
    print("Yes")
elif card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0:
    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 _ in range(N)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=-1

is_bingo=False
#行
for i in range(3):
    if A[i][0]==A[i][1]==A[i][2]==-1:
        is_bingo=True
        break
#列
for i in range(3):
    if A[0][i]==A[1][i]==A[2][i]==-1:
        is_bingo=True
        break
#ななめ
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

print("Yes" if is_bingo==True else "No")

Submission status: Accepted

Solution code:
A=[]
for i in range(3):
  B=list(map(int,input().split()))
  A.append(B)
N=int(input())
b=[0]*N
for i in range(N):
  b[i]=int(input())
lis=[]
bingo=[[(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 i in range(3):
  for j in range(3):
    if A[i][j] in b:
      lis.append((i,j))
ans=0
for i in range(8):
  count=0
  for j in range(3):
    if bingo[i][j] in lis:
      count+=1
  if count==3:
    ans+=1
    print('Yes')
    break
if ans==0:
  print('No')

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a = [list(map(int, readline().split())) for i in range(3)]
n = int(readline())
b = [int(readline()) for _ in range(n)]
for bb in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == bb:
                a[j][k] = 0
ans = 'No'
for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 0:
        ans = 'Yes'
    if a[0][i] == a[1][i] == a[2][i] == 0:
        ans = 'Yes'
if a[0][0] == a[1][1] == a[2][2] == 0:
    ans = 'Yes'
if a[2][0] == a[1][1] == a[0][2] == 0:
    ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
A = [input().split() for _ in range(3)]
n = int(input())
B = [input() for _ in range(n)]
ans = False
bng = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                bng[j][k] = 1

for i in range(3):
    if bng[i][0] == bng[i][1] == bng[i][2] == 1:
        ans = True
    if bng[0][i] == bng[1][i] == bng[2][i] == 1:
        ans = True

if bng[0][0] == bng[1][1] == bng[2][2] == 1:
    ans = True
if bng[0][2] == bng[1][1] == bng[2][0] == 1:
    ans = True

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

Submission status: Accepted

Solution code:
from itertools import product

A = [list(map(int,input().split())) for i in range(3)]
n = int(input())
crd = [[False,False,False] for i in range(3)]
for _ in range(n):
    b = int(input())
    for i,j in product(range(3),range(3)):
        if b == A[i][j]:
            crd[i][j] = True

line = [[(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)],[(2,0),(1,1),(0,2)]]


for l in line:
    if crd[l[0][0]][l[0][1]] and crd[l[1][0]][l[1][1]] and crd[l[2][0]][l[2][1]]:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
a11,a12,a13 = input().split()
a21,a22,a23 = input().split()
a31,a32,a33 = input().split()
A=[[a11,a12,a13],[a21,a22,a23],[a31,a32,a33]]
N = int(input())
b=[input() for i in range(N)]
bingo=[[False,False,False],[False,False,False],[False,False,False]]

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

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

Submission status: Accepted

Solution code:
import sys

row1 = [int(n) for n in input().split()]
row2 = [int(n) for n in input().split()]
row3 = [int(n) for n in input().split()]

card = [row1,row2,row3]

#print(card)

N = int(input())
for n in range(N):
    bn = int(input())
    for i in range(len(card)):
        for j in range(len(card)):
            if card[i][j] == bn:
                card[i][j] = 0

#print(card)

for i in range(len(card)):
    check_i = 0
    for j in range(len(card)):
        check_i += card[i][j]
    #print('check_i: ' + str(check_i))
    if check_i == 0:
        print('Yes')
        sys.exit(0)
for j in range(len(card)):
    check_j = 0
    for i in range(len(card)):
        check_j += card[i][j]
    #print("check_j: " + str(check_j))
    if check_j == 0:
        print('Yes')
        sys.exit(0)

check_diag1 = 0
check_diag2 = 0
for i in range(len(card)):
    check_diag1 += card[i][i]
    check_diag2 += card[len(card)-i-1][i]
#print('check_diag1: ' + str(check_diag1))
#print('check_diag2: ' + str(check_diag2))
if check_diag1 == 0 or check_diag2 == 0:
    print('Yes')
    sys.exit(0)

print('No')

Submission status: Accepted

Solution code:
def main():
    a = [[] for i in range(3)]

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

    n = int(input())

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

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

    if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
        ans = "Yes"
    if a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
        ans = "Yes"

    print(ans)

main()

Submission status: Accepted

Solution code:
import math
A=[list(map(int,input().split())) for n in range(3)]
N=int(input())
D=[int(input()) for i in range(N)]
F=[]
ans="No"
for d in D:
    for aa in A:
        for a in aa:
            if d==a:
               F.append([A.index(aa)+2,aa.index(d)+2])
            else:
                continue

for f1 in F:
    for f2 in F:
        for f3 in F:
            if f1==f2 or f2==f3 or f3==f1:
                continue
            elif math.atan2((f2[1]-f1[1]),(f2[0]-f1[0]))==math.atan2((f3[1]-f1[1]),(f3[0]-f1[0])):
                ans="Yes"
                break
            else:
                continue

print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = [LIST() for _ in range(3)]
N = INT()
b = [INT() for _ in range(N)]

for n in b:
  for i in range(3):
    for j in range(3):
      if A[i][j] == n:
        A[i][j] = 0
        
for i in range(3):
  if sum(A[i]) == 0:
    print("Yes")
    exit()
    
for i in range(3):
  if A[0][i] + A[1][i] + A[2][i] == 0:
    print("Yes")
    exit()
    
if A[0][0] + A[1][1] + A[2][2] == 0:
  print("Yes")
  exit()
  
if A[0][2] + A[1][1] + A[2][0] == 0:
  print("Yes")
  exit()
  
print("No")

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = [LIST() for _ in range(3)]
N = INT()
b = [INT() for _ in range(N)]

check = [[0]*3 for _ in range(3)]

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

for i in range(3):
  if sum(check[i]) == 3:
    print("Yes")
    exit()

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

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest

import numpy as np

def resolve():
    a = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    b = set([int(input()) for _ in range(n)])
    flag = 0

    for i in range(3):
        if set(a[i]).issubset(b) or set(a[:, i]).issubset(b):
            flag = 1
            break

    if set([a[0][0], a[1][1], a[2][2]]).issubset(b) or set([a[0][2], a[1][1], a[2][0]]).issubset(b):
        flag = 1

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



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """41 7 46
26 89 2
78 92 8
5
6
45
16
57
17"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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())
List=[]
List+=[a,b,c,d,e,f,g,h,i]
n=int(input())
lst=[int(input()) for i in range(n)]
p=set()
for i in lst:
  if i in List:
    p.add(List.index(i))
if 3 in p and 4 in p and 5 in p:
  print("Yes")
elif 0 in p and 1 in p and 2 in p:
  print("Yes")
elif 6 in p and 7 in p and 8 in p:
  print("Yes")
elif 0 in p and 3 in p and 6 in p:
  print("Yes")
elif 1 in p and 4 in p and 7 in p:
  print("Yes")
elif 2 in p and 5 in p and 8 in p:
  print("Yes")
elif 0 in p and 4 in p and 8 in p:
  print("Yes")
elif 2 in p and 4 in p and 6 in p:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
Asq = []
for i in range(3) :
    Asq.append(list(input().split()))

N = int(input())
b = []
c = 0
y = 0
for k in range(N) :
    b.append(input())
    for i in range(3) :
        for j in range(3) :
            if Asq[i][j] == b[k] :
                s = Asq[i][j]
                Asq[i][j] = '#'
                c += 1

if c >= 3 :
    for i in range(3) :
        if (Asq[i][0] == '#') and (Asq[i][1] == '#') and (Asq[i][2] == '#') :
            y = 1
        elif (Asq[0][i] == '#') and (Asq[1][i] == '#') and Asq[2][i] == '#' :
            y = 1
    if Asq[0][0] == '#' and Asq[1][1] == '#' and Asq[2][2] == '#' :
        y = 1
    elif Asq[0][2] == '#' and Asq[1][1] == '#' and Asq[2][0] == '#' :
        y = 1

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

Submission status: Accepted

Solution code:
a = [list( input().split()) for _ in range(3)]

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

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

Submission status: Accepted

Solution code:
def read():
    board = []
    for _ in range(3):
        board.append([int(num) for num in input().split()])
    return board

board = read()
N = int(input())
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if board[i][j] == b:
                board[i][j] = True

good = False

for i in range(3):
    if board[i][0] == board[i][1] == board[i][2] == True:
        good = True
    if board[0][i] == board[1][i] == board[2][i] == True:
        good = True

if board[0][0] == board[1][1] == board[2][2] == True:
    good = True
if board[0][2] == board[1][1] == board[2][0] == True:
    good = True

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

Submission status: Accepted

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
    if a[z][0]==a[z][1]==a[z][2]=="x":
        c+=1
if c!=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()))
an = [a1, a2, a3]
n = int(input())
bn = []
counter = 0
for _ in range(n):
  bn.append(int(input()))
  
for i in bn:
  for j in an:
    if i in j:
      j[j.index(i)] = 0

for k in an:
  if k.count(0) == 3:
    print('Yes')
    exit()
    
for l in range(3):
  if an[0][l] == 0 and an[1][l] == 0 and an[2][l] == 0:
    print('Yes')
    exit()
    
if an[0][0] == 0 and an[1][1] == 0 and an[2][2] == 0:
  print('Yes')
  exit()
if an[0][2] == 0 and an[1][1] == 0 and an[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)]

for i in range(3):
  if a[0][i] in b and a[1][i] in b and a[2][i] in b:
    print('Yes')
    exit()
  if a[i][0] in b and a[i][1] in b and a[i][2] in b:
    print('Yes')
    exit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
    exit()
if a[2][0] in b and a[1][1] in b and a[0][2] 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)]

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

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

if a[0][0]+a[1][1] + a[2][2] == 0:
    print('Yes')
    exit()
if a[2][0]+a[1][1] + a[0][2] == 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 i in range(n)]
flag =False
for i in range(3):
  if all(a[i][j] in b for j in range(3)):
    flag=True
  if all(a[j][i] in b for j in range(3)):
    flag=True
if all(a[j][j] in b for j in range(3)) or all(a[i][2-i] in b for i in range(3)) :
  flag=True
if(flag):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a=[list(map(int,input().split())) for j 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]=0
ans="No"

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

Submission status: Accepted

Solution code:
A = [list(map(int, input().split())) for k in range(3)]
n = int(input())
B = [int(input()) for b in range(n)]
#print(A, B)

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

J_0 = A[0][0] + A[1][0] + A[2][0]
J_1 = A[0][1] + A[1][1] + A[2][1]
J_2 = A[0][2] + A[1][2] + A[2][2]
nana1 = A[0][0] + A[1][1] + A[2][2]
nana2 = A[0][2] + A[1][1] + A[2][0]
if sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[2]) == 0:
    print("Yes")
elif J_0 == 0 or J_1 == 0 or J_2 == 0:
    print("Yes")
elif nana1 == 0 or nana2 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
for j in range(int(input())):
  b = int(input())
  for h in range(3):
    for k in range(3):
      if a[h][k] == b:
        a[h][k] = 0

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

Submission status: Accepted

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 a:
        if b in j:
            j[j.index(b)]=0

if (a[0][1]==a[0][2]==a[0][0] 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:
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
for b in B:
    for i in range(3):
        if b in A[i]:
            A[i][A[i].index(b)]=0
            
a=[]
            
def tate(X,i,c):
    cnt=0
    for j in range(3):
        if X[j][i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)
        
def yoko(X,i,c):
    cnt=0
    for j in range(3):
        if X[i][j]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)
        
def naname(X,c):
    cnt=0
    for i in range(3):
        if X[i][i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)

def naname2(X,c):
    cnt=0
    for i in range(3):
        if X[i][2-i]==0:
            cnt+=1
        if cnt==3:
            return c.append(1)

            
for i in range(3):
    tate(A,i,a)
    yoko(A,i,a)
naname(A,a)
naname2(A,a)
    
if len(a)==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
line_a = list(map(int, input().split()))
line_b = list(map(int, input().split()))
line_c = list(map(int, input().split()))

bingo = line_a + line_b + line_c


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

for i in Bn:
  if i in bingo:
    n = bingo.index(i)
    bingo[n] = -1

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

Submission status: Accepted

Solution code:
a1 = input()
a2 = input()
a3 = input()
a1_list = a1.split(' ')
a2_list = a2.split(' ')
a3_list = a3.split(' ')

num = input()
num = int(num)
bingo = []

for i in range(num):
    y = input()
    bingo.append(y)

for i in bingo:
    i = str(i)
    for y in range(3):
        if a1_list[y] == i:
            a1_list[y] = 'OK'
        elif a2_list[y] == i:
            a2_list[y] = 'OK'
        elif a3_list[y] == i:
            a3_list[y] = 'OK'

bingo1 = (a1_list[0] == a1_list[1] and a1_list[1] == a1_list[2] and a1_list[2] == a1_list[0])
bingo2 = (a2_list[0] == a2_list[1] and a2_list[1] == a2_list[2] and a2_list[2] == a2_list[0])
bingo3 = (a3_list[0] == a3_list[1] and a3_list[1] == a3_list[2] and a3_list[2] == a3_list[0])
bingo4 = (a1_list[0] == a2_list[0] and a2_list[0] == a3_list[0] and a1_list[0] == a3_list[0])
bingo5 = (a1_list[1] == a2_list[1] and a2_list[1] == a3_list[1] and a1_list[1] == a3_list[1])
bingo6 = (a1_list[2] == a2_list[2] and a2_list[2] == a3_list[2] and a1_list[2] == a3_list[2])
bingo7 = (a1_list[0] == a2_list[1] and a2_list[1] == a3_list[2] and a1_list[0] == a3_list[2])
bingo8 = (a1_list[2] == a2_list[1] and a2_list[1] == a3_list[0] and a3_list[0] == a1_list[2])

if bingo1 or bingo2 or bingo3:
    print('Yes')
elif bingo4 or bingo5 or bingo6:
    print('Yes')
elif bingo7 or bingo8:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Bingo=[Bingocard[0][0],Bingocard[0][1],Bingocard[0][2],Bingocard[1][0],Bingocard[1][1],Bingocard[1][2],Bingocard[2][0],Bingocard[2][1],Bingocard[2][2]]

# Number of draws
Num = len(Draws)

# take for loop for number of draws...
# Notice that since bingo card value at least 1,
# can change to 0....

for i in range (0, Num):
	if Bingo.count(Draws[i])>0:
		Bingo[Bingo.index(Draws[i])]= 0
	else:
		continue

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

Submission status: Accepted

Solution code:
a=[list(map(int,input().split())) for j in range(3)]
for i in range(int(input())):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
              a[j][k]=0
ans="No"

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

Submission status: Accepted

Solution code:
import numpy as np

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

mask = np.zeros((3, 3))
for bi in b:
  mask += (a == bi)

flag = False
if mask[0, :].sum() >= 3 or mask[1, :].sum() >= 3 or mask[2, :].sum() >= 3:
    flag = True

if mask[:, 0].sum() >= 3 or mask[:, 1].sum() >= 3 or mask[:, 2].sum() >= 3:
    flag = True

if mask[0, 0] + mask[1, 1] + mask[2, 2] >= 3 or mask[2, 0] + mask[1, 1] + mask[0, 2] >= 3:
    flag = True

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

Submission status: Accepted

Solution code:
a=[]
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
a.append(list(map(int,input().split())))
n=int(input())
for _ 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
ans = 0
for i in range(3):
    if sum(a[i]) == 0:
        ans+=1
    if sum([a[j][i] for j in range(3)]) == 0:
        ans+=1
if a[0][0]+a[1][1]+a[2][2]==0:
     ans +=1
if a[2][0]+a[1][1]+a[0][2]==0:
     ans +=1
print('Yes' if ans > 0 else 'No')

Submission status: Accepted

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
for i in range(int(input())):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:a[j][k]=0
ans="No"

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

Submission status: Accepted

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

for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      A[i][j] = 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[2][0]+A[1][1]+A[0][2] ==0:
    judge += 1
  
  else:
    judge += 0
    
if judge >= 1:
  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 _ in range(N)]

l = [[(a_i in B) for a_i in a] for a in A]

x = [
    [(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)],
]

flag = any(all(l[y][x] for x, y in pos_l) for pos_l in x)
# print(l)

# flag = 0
# for y in range(3):
#     flag |= all(l[y])

# for x in range(3):
#     flag |= all([l[x][y] for y in range(3)])

# flag |= all([l[y][x] for x, y in [(0, 0), (1, 1), (2, 2)]])

# flag |= all([l[y][x] for x, y in [(0, 2), (1, 1), (2, 0)]])

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

Submission status: Accepted

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

for _ in range(N):
    b = int(input())
    for y in range(3):
        for x in range(3):
            if A[y][x] == b:
                A[y][x] = -1

for y in range(3):
    f = True
    for x in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

for x in range(3):
    f = True
    for y in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

f = True
for x in range(3):
    if A[x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

f = True
for x in range(3):
    if A[2 - x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
A = []
B = []
cnt = 0

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

N = int(input())

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

for i in range(3):
    for j in range(3):
        for k in B:
            if A[i][j] == k:
                A[i][j] = 0
import sys
for i in range(3):            
    if A[i][0]==0 and A[i][0]==A[i][1] and A[i][1]==A[i][2]:
        print('Yes')
        sys.exit()
    elif A[0][i]==0 and A[0][i]==A[1][i] and A[1][i]==A[2][i]:
        print('Yes')
        sys.exit()
    elif A[0][0]==0 and A[0][0]==A[1][1] and A[1][1]==A[2][2]:
        print('Yes')
        sys.exit()
    elif A[0][2]==0 and A[0][2]==A[1][1] and A[1][1]==A[2][0]:
        print('Yes')
        sys.exit()

print('No')

Submission status: Accepted

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

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

ans = 'No'

for i in range(3):
  if sum(b[i]) == 3:
    ans = 'Yes'
    break

for i in range(3):
  if sum([b[j][i] for j in range(3)]) == 3:
    ans = 'Yes'
    break

if sum([b[i][i] for i in range(3)]) == 3:
  ans = 'Yes'

if sum([b[i][2-i] for i in range(3)]) == 3:
  ans = 'Yes'
  
print(ans)