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:
import math
def main():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for _ in range(n):
        x = int(input())
        a = [True if i == x else i for i in a]
    a = [False if i != True else True for i in a]
    if all(a[0:3]) or all(a[3:6]) or all(a[6:]):
        print("Yes")
    elif all(a[0::3]) or all(a[1::3]) or all(a[2::3]):
        print("Yes")
    elif all(a[0::4]) or all(a[2:7:2]):
        print("Yes")
    else:
        print("No")
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

Data = []
Status = [[0]*3 for _ in range(3)]
for i in range(3):
    Data.append(list(map(int,input().split())))
N = int(input())
for i in range(N):
    b = int(input())
    
    for y in range(3):
        for x in range(3):
            if b == Data[y][x]:
                Status[y][x] = 1

for y in range(3):
    if Status[y][0] == 1 and Status[y][1] == 1 and Status[y][2] == 1:
        print('Yes')
        sys.exit()
for x in range(3):
    if Status[0][x] == 1 and Status[1][x] == 1 and Status[2][x] == 1:
        print('Yes')
        sys.exit()
if Status[0][0] == 1 and Status[1][1] == 1 and Status[2][2] == 1:
    print('Yes')
    sys.exit()
if Status[0][2] == 1 and Status[1][1] == 1 and Status[2][0] == 1:
    print('Yes')
    sys.exit()
print('No')

Submission status: Accepted

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

for x in b:
    for i in range(3):
        for j in range(3):
            if x == a[i][j]:
                a[i][j] = -1
ans = 'No'
for i in range(3):
    if a[i][0] == a[i][1] and a[i][1] == a[i][2]:
        ans = 'Yes'

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def inlt():
    return(list(map(int, input().split())))


def inp():
    return(int(input()))


A = []
for t in range(3):
    A.append(inlt())

n = inp()
for t in range(n):
    b = inp()
    # mark the position of b
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0
res = "No"
# see row wise:
for i in range(3):
    s = 0
    for j in range(3):
        s += A[i][j]
    if s == 0:
        res = "Yes"
        break
# see column wise
for i in range(3):
    s = 0
    for j in range(3):
        s += A[j][i]
    if s == 0:
        res = "Yes"
        break
# see diagonal
s = 0
for i in range(3):
    for j in range(3):
        if i == j:
            s += A[j][i]
if s == 0:
    res = "Yes"

s = 0
for i in range(3):
    for j in range(3):
        if i == j:
            s += A[j][i]
if s == 0:
    res = "Yes"

if A[0][2] == A[1][1] == A[2][0]:
    res = "Yes"

print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
for x in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == x:
                a[i][j] = 0
ans = False
if all(a[i][i] == 0 for i in range(3)):
    ans = True
if all(a[i][~i] == 0 for i in range(3)):
    ans = True
for i in range(3):
    if all(a[i][j] == 0 for j in range(3)):
        ans = True
    if all(a[j][i] == 0 for j in range(3)):
        ans = True
print(["No", "Yes"][ans])

Submission status: Accepted

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

if A[0] == 0 and A[1] == 0 and A[2] == 0:
    print('Yes')
elif A[3] == 0 and A[4] == 0 and A[5] == 0:
    print('Yes')
elif A[6] == 0 and A[7] == 0 and A[8] == 0:
    print('Yes')
elif A[0] == 0 and A[3] == 0 and A[6] == 0:
    print('Yes')
elif A[1] == 0 and A[4] == 0 and A[7] == 0:
    print('Yes')
elif A[2] == 0 and A[5] == 0 and A[8] == 0:
    print('Yes')
elif A[0] == 0 and A[4] == 0 and A[8] == 0:
    print('Yes')
elif A[2] == 0 and A[4] == 0 and A[6] == 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())
ans = 'No'
for i in range(n):
    d = int(input())
    for i in range(3):
        for j in range(3):
            if d == a[i][j]:
                a[i][j]=0

if a[0][0] == 0 and a[1][1] == 0 and a[2][2]==0:
    ans = 'Yes'
elif a[0][2] == 0 and a[1][1] == 0 and a[2][0]==0:
    ans = 'Yes'
else: 
    for l in a:
        if sum(l)==0:
            ans = 'Yes'
            break
    for l in zip(*a):
        if sum(l)==0:
            ans = 'Yes'
            break
        

print(ans)

Submission status: Accepted

Solution code:
a1x = [int(x) for x in input().split(' ')]
a2x = [int(x) for x in input().split(' ')]
a3x = [int(x) for x in input().split(' ')]

sheet = [a1x, a2x, a3x]

n = int(input())
numbers = []

for i in range(n):
    num = int(input())
    numbers.append(num)

def solve(n, sheet, numbers):
    for number in numbers:
        for row in range(3):
            for column in range(3):
                if sheet[row][column] == number:
                    sheet[row][column] = "X"

    if checkRow(sheet) or checkColumn(sheet) or checkDiagonals(sheet):
        print("Yes")
    else:
        print("No")

def checkRow(sheet):
    for row in range(3):
        marked = 0
        for column in range(3):
            if sheet[row][column] == "X":
                marked += 1
        if marked == 3:
            return True
    
    return False
            
def checkColumn(sheet):
    for row in range(3):
        marked = 0
        for column in range(3):
            if sheet[column][row] == "X":
                marked += 1
        if marked == 3:
            return True
    
    return False

def checkDiagonals(sheet):
    marked = 0
    for i in range(3):
        if sheet[i][i] == "X":
            marked += 1

    if marked != 3:
        marked = 0
        for j in range(3):
            if sheet[j][2-j] == "X":
                marked += 1
    
    if marked == 3:
        return True
    else:
        return False

    

solve(n, sheet, numbers)

Submission status: Accepted

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

bingo = False
for i in range(3):
    if grid[i][0] == grid[i][1] == grid[i][2] == 0:
        bingo = True
for i in range(3):
    if grid[0][i] == grid[1][i] == grid[2][i] == 0:
        bingo = True
if grid[0][0] == grid[1][1] == grid[2][2] == 0:
    bingo = True
if grid[0][2] == grid[1][1] == grid[2][0] == 0:
    bingo = True

if bingo:
    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 ck in b:
    for i in range(3):
        for j in range(3):
            if ck == A[i][j]:
                A[i][j] = 0

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

Submission status: Accepted

Solution code:
def resolve():
    a=[-1]
    for  _ in range(3):
        a.extend(list(map(int,input().split())))
    n=int(input())
    for _ in range(n):
        b=int(input())
        if b in a:
            a[a.index(b)]=0
    if a[1]==a[2]==a[3]==0 or a[4]==a[5]==a[6]==0 or a[7]==a[8]==a[9]==0 or a[1]==a[4]==a[7]==0 or a[2]==a[5]==a[8] or a[3]==a[6]==a[9]==0 or a[1]==a[5]==a[9]==0 or a[3]==a[5]==a[7]==0:
        print("Yes")
    else:
        print("No")        
resolve()

Submission status: Accepted

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

for i in b:
    if i in a:
        x = a.index(i)
        c[x] = 1

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

Submission status: Accepted

Solution code:

t = [[int(j) for j in input().split()] for i in range(3)]
l = sum(t, [])
N = int(input())
for _ in range(N):
    i = int(input())
    for j in range(9):
        if i == l[j]:
            l[j] = 0
a, b, c, d, e, f, g, h, i = l
if (a == 0 and d == 0 and g == 0) \
or (b == 0 and e == 0 and h == 0) \
or (c == 0 and f == 0 and i == 0) \
or (a == 0 and b == 0 and c == 0) \
or (d == 0 and e == 0 and f == 0) \
or (g == 0 and h == 0 and i == 0) \
or (a == 0 and e == 0 and i == 0) \
or (c == 0 and e == 0 and g == 0):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
t = [[int(j) for j in input().split()] for i in range(3)]
l = sum(t, [])
N = int(input())
for _ in range(N):
    i = int(input())
    for j in range(9):
        if i == l[j]:
            l[j] = 0
a, b, c, d, e, f, g, h, i = l
if (a == 0 and d == 0 and g == 0) \
or (b == 0 and e == 0 and h == 0) \
or (c == 0 and f == 0 and i == 0) \
or (a == 0 and b == 0 and c == 0) \
or (d == 0 and e == 0 and f == 0) \
or (g == 0 and h == 0 and i == 0) \
or (a == 0 and e == 0 and i == 0) \
or (c == 0 and e == 0 and g == 0):
    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())
n = int(input())
b = [int(input()) for i in range(n)]
c = 0
if a11 in b and a12 in b and a13 in b:
    c += 1
if a21 in b and a22 in b and a23 in b:
    c += 1
if a31 in b and a32 in b and a33 in b:
    c += 1
if a11 in b and a21 in b and a31 in b:
    c += 1
if a12 in b and a22 in b and a32 in b:
    c += 1
if a13 in b and a23 in b and a33 in b:
    c += 1
if a11 in b and a22 in b and a33 in b:
    c += 1
if a13 in b and a22 in b and a31 in b:
    c += 1
if c > 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 = [0] * n
for i in range(n):
    b[i] = int(input()) 


ans = [[0 for i in range(3)]  for j in range(3)]

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

hantei = False
for i in range(3):
    if ans[i] == [1,1,1]:
        hantei = True
    if ans[0][i] == 1 and ans[1][i] == 1 and ans[2][i] == 1:
        hantei = True

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

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

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

Submission status: Accepted

Solution code:
a = []
for i in range(3):
    a+=list(map(int,input().split()))
n = int(input())
b = [int(input()) for i in range(n)]
n_a = [0 for i in range(9)]
for i in b:
    for j in a:
        if i == j:
            n_a[a.index(j)]+=1


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

Submission status: Accepted

Solution code:
import numpy as np
A = np.array(sum((input().split() for _ in range(3)), []), dtype=np.int8)
N = int(input())
for _ in range(N):
    np.multiply(A, A != int(input()), out=A)
A.resize(3, 3)
print("YNeos"[np.trace(A) and np.trace(np.rot90(A)) and A.sum(axis=0).all() and A.sum(axis=1).all()::2])

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 i in range(3):
    for j in range(3):
        if a[i][j] in b:
             a[i][j] = 0

import numpy as np 

arr = np.array(a)

answer = "No"
if (0 in arr.sum(axis=0)) or (0 in arr.sum(axis=1)):
    answer = "Yes"
elif arr.diagonal().sum() == 0 or np.fliplr(arr).diagonal().sum() == 0: # 行列左右反転　fliplr()
    answer = "Yes"

print(answer)

Submission status: Accepted

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

i = 0
while i<N:
  b = int(input())
  j=0
  while j<3:
    k=0
    while k<3:
      if A[j][k]==b:
        A[j][k]=0
      k+=1
    j+=1
  i+=1

flag = False
i = 0
while i<3:
  if A[i][0]+A[i][1]+A[i][2] == 0:
    flag = True
    break
  if A[0][i]+A[1][i]+A[2][i] == 0:
    flag = True
    break
  i += 1

if A[0][0]+A[1][1]+A[2][2] == 0:
  flag = True
if A[2][0]+A[1][1]+A[0][2] == 0:
  flag = True

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

Submission status: Accepted

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

bingo = np.array([A_1, A_2, A_3])
N = int(input())
for i in range(N):
    bingo[bingo == int(input())] = 0

def check():
    for i in range(3):
        if bingo[i][0] == 0 and bingo[i][1] == 0 and bingo[i][2] == 0:
            return True
        if bingo[0][i] == 0 and bingo[1][i] == 0 and bingo[2][i] == 0:
            return True
    if bingo[0][0] == 0 and bingo[1][1] == 0 and bingo[2][2] == 0:
        return True
    if bingo[0][2] == 0 and bingo[1][1] == 0 and bingo[2][0] == 0:
        return True

if check():
    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 i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
ans = "No"
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    elif 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"
elif a[0][2] + a[1][1] + a[2][0] ==0:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
A = list(list(map(int, input().split())) for i in range(3))
N = int(input())
B = [int(input()) for i in range(N)]
result = [[0]*3 for i in range(3)]
#print(A, N, B, result)

for i in range(3):
    for j in range(3):
        for k in range(N):
            #print(A[i][j], B[k])
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

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

Submission status: Accepted

Solution code:

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

for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

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

Submission status: Accepted

Solution code:
def check(T):
    column = any([all( [T[i][j] for j in range(3)] ) for i in range(3)])
    row = any([all( [T[j][i]for j in range(3)] ) for i in range(3)])
    diagonal = all( [T[i][i] for i in range(3)]) or all( [T[i][2-i] for i in range(3)])
    return row or column or diagonal

a = 3
grid =[[0]*a for i in range(a)]

d = {}
for i in range(3):
    row = list(map(int,input().split()))
    for j in range(3):
        d[row[j]] = (i,j)


N = int(input())
for i in range(N):
    p = int(input())

    if p in d.keys():
        x,y = d[p]
        grid[x][y] = 1

print( "Yes" if check(grid) else "No")

Submission status: Accepted

Solution code:
listA = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == listA[j][k]:
                listA[j][k] = 0
for l in range(3):
    if listA[l].count(0) == 3:
        print('Yes')
        exit()
    elif listA[0][l] == 0 and listA[1][l] == 0 and listA[2][l] == 0:
        print('Yes')
        exit()
if listA[0][0] == 0 and listA[1][1] == 0 and listA[2][2] == 0:
    print('Yes')
elif listA[0][2] == 0 and listA[1][1] == 0 and listA[2][0] == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=3
a=[[0]*n for ii in range(n)]
for ii in range(n):
  a[ii][:]=map(int,input().split())
m=int(input())
b=[0]*m
for ii in range(m):
  b[ii]=int(input())
#print(a)
c=[[1 if jj in b else 0 for jj in ii] for ii in a]
#print(c)
for ii in range(n):
  if sum(c[ii])==3:
    print("Yes")
    exit()
  if sum([c[jj][ii] for jj in range(n)])==3:
    print("Yes")
    exit()
if sum([c[jj][jj] for jj in range(n)])==3:
  print("Yes")
  exit()
if sum([c[jj][n-1-jj] for jj in range(n)])==3:
  print("Yes")
  exit()
print("No")

Submission status: Accepted

Solution code:
A = []
B = [[False for _ in range(3)] for __ in range(3) ]
for i in range(3):
    a = list(map(int, input().split()))
    A.append(a)

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:
                B[i][j] = True

ansFlag = False

for i in range(3):
    ansi = True
    for j in range(3):
        if B[i][j] == False:
            ansi = False

    if ansi:
        ansFlag = True

for i in range(3):
    ansi = True
    for j in range(3):
        if B[j][i] == False:
            ansi = False

    if ansi:
        ansFlag = True

ansi = True
for j in range(3):
    if B[2-j][j] == False:
        ansi = False

if ansi:
    ansFlag = True

ansi = True
for j in range(3):
    if B[j][2-j] == False:
        ansi = False

if ansi:
    ansFlag = True

ansi = True
for j in range(3):
    if B[j][j] == False:
        ansi = False

if ansi:
    ansFlag = True

ansi = True
for j in range(3):
    if B[2-j][2-j] == False:
        ansi = False

if ansi:
    ansFlag = True

if ansFlag:
    print("Yes")
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):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:
        a[j][k]=0

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

if a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
  ans=1
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
  ans=1

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

Submission status: Accepted

Solution code:
bingo=[list(input().split()) for i in range(3)]
n=int(input())
ans=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
    a=input()
    for j in range(3):
        for k,l in enumerate(bingo[j]):
            if a==l:
                ans[j][k]=1 
if (ans[0][0]==ans[0][1]==ans[0][2]==1)\
    or (ans[1][0]==ans[1][1]==ans[1][2]==1)\
        or (ans[2][0]==ans[2][1]==ans[2][2]==1) \
            or (ans[0][0]==ans[1][0]== ans[2][0]==1) \
                or (ans[0][1]==ans[1][1]==ans[2][1]==1) \
                    or (ans[0][2]==ans[1][2]==ans[2][2]==1) \
                        or (ans[0][0]==ans[1][1]==ans[2][2]==1) \
                            or (ans[0][2]==ans[1][1]==ans[2][0]==1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
bingo=[list(input().split()) for i in range(3)]
n=int(input())
ans=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
    a=input()
    for j in range(3):
        for k,l in enumerate(bingo[j]):
            if a==l:
                ans[j][k]=1 
if (ans[0][0]==1 and ans[0][1]==1 and ans[0][2]==1) or (ans[1][0]==1 and ans[1][1]==1 and ans[1][2]==1) or (ans[2][0]==1 and ans[2][1]==1 and ans[2][2]==1) or (ans[0][0]==1 and ans[1][0]==1 and ans[2][0]==1) or (ans[0][1]==1 and ans[1][1]==1 and ans[2][1]==1) or (ans[0][2]==1 and ans[1][2]==1 and ans[2][2]==1) or (ans[0][0]==1 and ans[1][1]==1 and ans[2][2]==1) or (ans[0][2]==1 and ans[1][1]==1 and ans[2][0]==1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

i = 10
call = []
try:
    for j in range(i):
        n = input()
        if (n == ''):
            break

        call.append(int(n))
except EOFError:
    pass

bingo = []

bingo.append(a)
bingo.append(b)
bingo.append(c)
bingo.append([a[0], b[0], c[0]])
bingo.append([a[1], b[1], c[1]])
bingo.append([a[2], b[2], c[2]])
bingo.append([a[0], b[1], c[2]])
bingo.append([a[2], b[1], c[0]])

ans = True
test = []
for ls in bingo:
    for num in ls:
        ans = ans and (num in call)

    if ans == True:
        print('Yes')
        exit(0)

    ans = True

print('No')

Submission status: Accepted

Solution code:
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
list3 = list(map(int, input().split()))
n = int(input())
num_list = []
for i in range(n):
    b = int(input())
    num_list.append(b)
for num in num_list:
    if num in list1:
        x = list1.index(num)
        list1.pop(x)
        list1.insert(x, 'bingo')
    if num in list2:
        x = list2.index(num)
        list2.pop(x)
        list2.insert(x, 'bingo')
    if num in list3:
        x = list3.index(num)
        list3.pop(x)
        list3.insert(x, 'bingo')
result = 'No'
if list1[0] == list1[1] == list1[2] == 'bingo':
    result = 'Yes'
if list2[0] == list2[1] == list2[2] == 'bingo':
    result = 'Yes'
if list3[0] == list3[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[0] == list3[0] == 'bingo':
    result = 'Yes'
if list1[1] == list2[1] == list3[1] == 'bingo':
    result = 'Yes'
if list1[2] == list2[2] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[2] == list2[1] == list3[0] == 'bingo':
    result = 'Yes'

print(result)

Submission status: Accepted

Solution code:
a=[input().split() for i in range(3)]
N=int(input())
B=list(map(int,[input() for i in range(1,N+1)]))

A1=list(map(int,a[0]))
A2=list(map(int,a[1]))
A3=list(map(int,a[2]))

if (A1[0] in B)==True and (A1[1] in B)==True and (A1[2] in B)==True:
    print("Yes")
elif (A2[0] in B)==True and (A2[1] in B)==True and (A2[2] in B)==True:
    print("Yes")
elif (A3[0] in B)==True and (A3[1] in B)==True and (A3[2] in B)==True:
    print("Yes")
elif (A1[0] in B)==True and (A2[0] in B)==True and (A3[0] in B)==True:
    print("Yes")
elif (A1[1] in B)==True and (A2[1] in B)==True and (A3[1] in B)==True:
    print("Yes")
elif (A1[2] in B)==True and (A2[2] in B)==True and (A3[2] in B)==True:
    print("Yes")
elif (A1[0] in B)==True and (A2[1] in B)==True and (A3[2] in B)==True:
    print("Yes")
elif (A1[2] in B)==True and (A2[1] in B)==True and (A3[0] in B)==True:
    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())

bingo = [[False]*3 for i in range(3)]
num = [[-1]*2 for i in range(101)]
for i in range(3):
    for j in range(3):
        num[A[i][j]][0] = i
        num[A[i][j]][1] = j

for i in range(n):
    index = int(input())
    x,y = num[index]
    if(x==-1 or y==-1):
        continue
    bingo[x][y]=True

isOk = False
#縦
for i in range(3):
    cnt = 0
    for j in range(3):
        if(bingo[i][j]):
            cnt+=1
        if(cnt==3):
            isOk = True
            break

#横
for i in range(3):
    cnt = 0
    for j in range(3):
        if(bingo[j][i]):
            cnt+=1
        if(cnt==3):
            isOk = True
            break

#斜め
if(bingo[0][0] and bingo[1][1] and bingo[2][2]):
    isOk = True

if(bingo[2][0] and bingo[1][1] and bingo[0][2]):
    isOk = True

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

Submission status: Accepted

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

for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
    if (
        A[0] + A[1] + A[2] == 0
        or A[3] + A[4] + A[5] == 0
        or A[6] + A[7] + A[8] == 0
        or A[0] + A[3] + A[6] == 0
        or A[1] + A[4] + A[7] == 0
        or A[2] + A[5] + A[8] == 0
        or A[0] + A[4] + A[8] == 0
        or A[2] + A[4] + A[6] == 0
    ):
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

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

ans = 0

for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
    if (
        A[0] + A[1] + A[2] == 0
        or A[3] + A[4] + A[5] == 0
        or A[6] + A[7] + A[8] == 0
        or A[0] + A[3] + A[6] == 0
        or A[1] + A[4] + A[7] == 0
        or A[2] + A[5] + A[8] == 0
        or A[0] + A[4] + A[8] == 0
        or A[2] + A[4] + A[6] == 0
    ):
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
A=[]
for i in range(3):
    P=list(map(int,input().split()))
    A.append(P)
N=int(input())
b=[]
for i in range(N):
    p=int(input())
    b.append(p)
    
for i in range(N):
    for j in range(3):
        if b[i] in  A[j]:
            q= A[j].index(b[i])
            A[j][q]='O'

if A[0].count('O')==3:
    print('Yes')
elif A[1].count('O')==3:
    print('Yes')
elif A[2].count('O')==3:
    print('Yes')
elif A[0][0]==A[1][0] and A[1][0]==A[2][0]:
    print('Yes')
elif A[0][1]==A[1][1] and A[1][1]==A[2][1]:
    print('Yes')
elif A[0][2]==A[1][2] and A[1][2]==A[2][2]:
    print('Yes')
elif A[0][0]==A[1][1] and A[1][1]==A[2][2]:
    print('Yes')
elif A[0][2]==A[1][1] and A[1][1]==A[2][0]:
    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 = set(int(input()) for i in range(n))
res = False
for row in A:
    if all(x in B for x in row):
        res = True
for j in range(3):
    if all(A[i][j] in B for i in range(3)):
        res = True
if all(A[i][i] in B for i in range(3)):
    res = True
if all(A[i][2 - i] in B for i in range(3)):
    res = True
print("Yes" if res else "No")

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 = [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
            
flag = False
for i in a:
    if sum(i)==-3:
        flag = True
for i in a.T:
    if sum(i)==-3:
        flag = True
if a.trace() == -3 or  sum([a[0][2], a[1][1], a[2][0]]) == -3:
    flag = True
    
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = list(list(map(int, input().split())) for i in range(3))
N = int(input())
B = [int(input()) for i in range(N)]
result = [[0]*3 for i in range(3)]
#print(A, N, B, result)

for i in range(3):
    for j in range(3):
        for k in range(N):
            #print(A[i][j], B[k])
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

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