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:
a = [list(map(int, input().split())) for l in range(3)]

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

for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
for r in range(3):
	if a[r][0]==a[r][1]==a[r][2]==0:
		print('Yes')
		exit()
	if a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')

Submission status: Accepted

Solution code:
row1 = list(map(int,input().split(" ")))
row2 = list(map(int,input().split(" ")))
row3 = list(map(int,input().split(" ")))

col1 = [row1[0],row2[0],row3[0]]
col2 = [row1[1],row2[1],row3[1]]
col3 = [row1[2],row2[2],row3[2]]

dig1 = [row1[0],row2[1],row3[2]]
dig2 =[row1[2],row2[1],row3[0]]

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

if all([ele in res for ele in row1]) or all([ele in res for ele in row2]) or all([ele in res for ele in row3]) or all([ele in res for ele in col1]) or all([ele in res for ele in col2]) or all([ele in res for ele in col3]) or all([ele in res for ele in dig1]) or all([ele in res for ele in dig2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
card = []

for _ in range(3):
    card.extend(map(int, input().split(' ')))

jadge = [0] * 9
N = int(input())

for _ in range(N):
    n = int(input())
    if n in card:
        jadge[card.index(n)] = 1

bingo = False
for i in range(3):
    if (jadge[3 * i] + jadge[3 * i+1] + jadge[3 * i+2]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[3 + i] + jadge[6 + i]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[4] + jadge[8-i]) == 3:
        bingo = True
        break

if bingo:
    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()))
seat = [a1, a2, a3]
n = int(input())
b = [int(input()) for i in range(n)]

seat_tf = [[False, False, False] for _ in range(3)]

for k in b:
    for i in range(3):
        for j in range(3):
            if seat[i][j] == k:
                seat_tf[i][j] = True

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

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

if (seat_tf[0][0] and seat_tf[1][1] and seat_tf[2][2]) or (seat_tf[0][2] and seat_tf[1][1] and seat_tf[2][0]):
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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

N = int(input())
b = [int(input()) for i in range(N)]
for i in range(len(b)):
    if b[i] in A_flat:
        index = A_flat.index(b[i])
        A_flat[index] = 0

judge=False
for i in range(3):
    if A_flat[0+i] == A_flat[3+i] == A_flat[6+i]:
        print("Yes")
        judge = True
        break
    elif A_flat[0+i*3]==A_flat[1+i*3]==A_flat[2+i*3]:
        print("Yes")
        judge = True
        break
    elif A_flat[0]==A_flat[4]==A_flat[8] or A_flat[2]==A_flat[4]==A_flat[6]:
        print("Yes")
        judge = True
        break

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

Submission status: Accepted

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

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a21,a22,a23 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))

#####################

card = [a11,a12,a13,a21,a22,a23,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0


def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    # col
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    # diagonal
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False


if check(card):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = []
for rep in range(3):
	a.append(list(map(int,input().split())))
n = int(input())
b = []
for rep in range(n):
    b.append(int(input()))
row = [0,0,0]
col = [0,0,0]
mid = 0
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            row[i] += 1
            col[j] += 1
            if i==1 and j==1:
                mid = 1
f = 1
for rep in range(3):
    if row[rep]==0 or col[rep]==0:
        f = 0
        break
if 3 in row or 3 in col:
    print("Yes")
elif f == 1 and mid == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

ans = "No"
if [A[i][i] for i in range(3)] == [0, 0, 0]:
    ans = "Yes"
if [A[i][2-i] for i in range(3)] == [0, 0, 0]:
    ans = "Yes"
for i in range(3):
    if A[i] == [0, 0, 0]:
        ans = "Yes"
    if [A[j][i] for j in range(3)] == [0, 0, 0]:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def main():
    # write codes here
    A = LIR(3)
    N = I()
    B = IR(N)

    bingo_card = [[0, 0, 0] for i in range(3)]

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

    flag = 0

    for i in range(3):
        if sum(bingo_card[i]) == 3:
            flag = 1
            break

        if bingo_card[0][i] + bingo_card[1][i] + bingo_card[2][i] == 3:
            flag = 1
            break

    if sum([bingo_card[i][i] for i in range(3)]) == 3:
        flag = 1

    if sum([bingo_card[i][2 - i] for i in range(3)]) == 3:
        flag = 1

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

    return 0


# Main
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a1 = [int(e) for e in input().split()]
a2 = [int(e) for e in input().split()]
a3 = [int(e) for e in input().split()]
n = int(input())
bs = []
for _ in range(n):
    bs.append(int(input()))

def is_bingo(mat,hits):
    row_pattern = [[mat[i][j] for j in range(3)] for i in range(3)]
    col_pattern = [[mat[j][i] for j in range(3)] for i in range(3)]
    cross_patten= [[mat[i][i] for i in range(3)] , [mat[0][2],mat[1][1],mat[2][0]]]
    if any([set(pattern).issubset(hits) for pattern in row_pattern+col_pattern+cross_patten]):
        return True
    return False
  
m=[a1,a2,a3]
print('Yes' if is_bingo(m,bs) else 'No')

Submission status: Accepted

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

ans = 'No'
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:
        ans = 'Yes'
if a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
    ans = 'Yes'

print(ans)

Submission status: Accepted

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

result = [[False, False, False], [False, False, False], [False, False, False]]
chk = 0
for r_idx, row in enumerate(table):
    for c_idx, col in enumerate(row):
        result[r_idx][c_idx] = col in p_list


for i in range(3):
    if result[i][0] and result[i][1] and result[i][2]:
        chk += 1
    if result[0][i] and result[1][i] and result[2][i]:
        chk += 1

if result[0][0] and result[1][1] and result[2][2]:
    chk += 1

if result[0][2] and result[1][1] and result[2][0]:
    chk += 1

print('Yes' if chk > 0 else '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)]
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
for i in range(3):
  cnth=0
  cntw=0
  for j in range(3):
    cnth+=result[i][j]
    cntw+=result[j][i]
  if cnth==3 or cntw==3:
    print('Yes')
    exit()
if result[0][0]==result[1][1]==result[2][2]==1 or result[0][2]==result[1][1]==result[2][0]==1:
  print('Yes')
  exit()
print('No')

Submission status: Accepted

Solution code:
import sys

As = []
for i in range(3):
    tmp = list(map(int, input().split()))
    for j in range(3):
        As.append({'value': tmp[j], 'isMarked': False})


N = int(input())

for i in range(N):
    b = int(input())
    for Ai in As:
        if Ai['value'] == b:
            Ai['isMarked'] = True

bingo_list = [[0,1,2],[3,4,5],[6,7,8],  # 横
              [0,3,6],[1,4,7],[2,5,8],  # 縦
              [0,4,8],[2,4,6]]          # ななめ

for bingo in bingo_list:
    if As[bingo[0]]['isMarked'] and As[bingo[1]]['isMarked'] and As[bingo[2]]['isMarked']:
        print('Yes')
        sys.exit(0)

print('No')

Submission status: Accepted

Solution code:
A = [list(map(int,input().split())) for i in range(3)]
B = [[False for i in range(3)] for j in range(3)]
N = int(input())
for k 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
ans = 'No'
if B[0][0] and B[0][1] and B[0][2]:
    ans = 'Yes'
if B[1][0] and B[1][1] and B[1][2]:
    ans = 'Yes'
if B[2][0] and B[2][1] and B[2][2]:
    ans = 'Yes'
if B[0][0] and B[1][0] and B[2][0]:
    ans = 'Yes'
if B[0][1] and B[1][1] and B[2][1]:
    ans = 'Yes'
if B[0][2] and B[1][2] and B[2][2]:
    ans = 'Yes'
if B[0][0] and B[1][1] and B[2][2]:
    ans = 'Yes'
if B[0][2] and B[1][1] and B[2][0]:
    ans = 'Yes'
print(ans)

Submission status: Accepted

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

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

flag = [[False] * 3 for i in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                flag[i][j] = True
                break

ans = False
for i in range(3):
    if flag[i].count(True) == 3:
        ans = True
    if [f[i] for f in flag].count(True) == 3:
        ans = True
if flag[0][0] == flag[1][1] == flag[2][2] == True or flag[0][2] == flag[1][1] == flag[2][0] == True:
    ans = True

print('Yes' if ans else 'No')

Submission status: Accepted

Solution code:
a = []
bingo = [[False for _ in range(3)] for __ in range(3)]
for _ in range(3):
  a.append(list(map(int, input().split())))
n = int(input())
for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b == a[j][k]:
        bingo[j][k] = True
n_bingo = 0
for r in range(3):
  if bingo[r][0] and bingo[r][1] and bingo[r][2]:
    n_bingo += 1
for c in range(3):
  if bingo[0][c] and bingo[1][c] and bingo[2][c]:
    n_bingo += 1
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
  n_bingo += 1
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
  n_bingo += 1

if n_bingo > 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

n = int(input())

ans = "No"

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

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

Submission status: Accepted

Solution code:
import numpy as np

bingo = np.zeros([3,3])
check = np.zeros([3,3])
choice = []
flag = "No"

for i in range(3):
    a = input().split()
    a = [int(x) for x in a]
    bingo[i] = a
N = int(input())
for i in range(N):
    choice.append(int(input()))

convert = bingo.reshape([9])
for i in range(9):
    for j in choice:
        if(convert[i] == j):
            check[i//3][i%3] = 1
            continue

            
for i in range(3):
    if(check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1):
        flag = "Yes"
    elif(check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1):
        flag = "Yes"
if(check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1):
    flag = "Yes"
elif(check[2][0] == 1 and check[1][1] == 1 and check[0][2] == 1):
    flag = "Yes"

print(flag)

Submission status: Accepted

Solution code:
a=[]
for i in range(3):
    line=list(map(int,input().split()))
    a.append(line)
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
bingo=0
for i in range(3):
    sum_=0
    for j in range(3):
        sum_+=a[i][j]
    if sum_==0:
        bingo+=1
for i in range(3):
    sum_=0
    for j in range(3):
        sum_+=a[j][i]
    if sum_==0:
        bingo+=1
if a[0][0]+a[1][1]+a[2][2]==0:
    bingo+=1
if a[0][2]+a[1][1]+a[2][0]==0:
    bingo+=1
print("Yes" if 0<bingo else "No")

Submission status: Accepted

Solution code:
import sys

def calc_flag(b,a,flag):
    if b in a:
        # flag[a.index(b)] = 1
        l_index = [i for i, x in enumerate(a) if x == b]
        for l in l_index:
            flag[l]=1
    return flag

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

flag1 = [0,0,0]
flag2 = [0,0,0]
flag3 = [0,0,0]

for i in range(n):
    b = int(input())
    flag1 = calc_flag(b,a1,flag1)
    flag2 = calc_flag(b,a2,flag2)
    flag3 = calc_flag(b,a3,flag3)

# print(flag1,flag2,flag3)

for i in range(3): #tate
    if flag1[i]+flag2[i]+flag3[i]==3:
        print('Yes')
        sys.exit()

if flag1[0]+flag2[1]+flag3[2]==3 or flag1[2]+flag2[1]+flag3[0]==3: #naname
    print('Yes')
elif sum(flag1)==3 or sum(flag2)==3 or sum(flag3)==3: #yoko
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

n = int(input())

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

isBingo = False
bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 4, 6]]
for elem in bingo:
    if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o':
        isBingo = True
        break

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

Submission status: Accepted

Solution code:
#読み込み
bingo = []
for i in range(3):
    line = input().split(" ")
    bingo.append(line)

numbers = []
N = int(input())
for j in range(N):
    number = int(input())
    numbers.append(number)

#印付け
for i in range(3):
    for j in range(3):
        for k in range(N):
            if int(bingo[i][j]) == numbers[k]:
                bingo[i][j] = 101

#判定
if bingo[0][0] == bingo[0][1] == bingo[0][2]:
    print("Yes")
elif bingo[1][0] == bingo[1][1] == bingo[1][2]:
    print("Yes")
elif bingo[2][0] == bingo[2][1] == bingo[2][2]:
    print("Yes")
elif bingo[0][0] == bingo[1][0] == bingo[2][0]:
    print("Yes")
elif bingo[0][1] == bingo[1][1] == bingo[2][1]:
    print("Yes")
elif bingo[0][2] == bingo[1][2] == bingo[2][2]:
    print("Yes")
elif bingo[0][0] == bingo[1][1] == bingo[2][2]:
    print("Yes")
elif bingo[0][2] == bingo[1][1] == bingo[2][0]:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
#B
a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
b=[int(input()) for i in range(n)]
appear=[[False]*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]:
                appear[i][j]=True
                break
ans="No"
for i in range(3):
    if appear[i][0]==appear[i][1]==appear[i][2]==True:
        ans="Yes"
    if appear[0][i]==appear[1][i]==appear[2][i]==True:
        ans="Yes"
if appear[0][0]==appear[1][1]==appear[2][2]==True:
    ans="Yes"
if appear[2][0]==appear[1][1]==appear[0][2]==True:
    ans="Yes"
print(ans)

Submission status: Accepted

Solution code:
import sys
card = [[int(x) for x in input().split(' ') ] for _ in range(3)]

patterns = []

patterns += [[card[i][j] for i in range(3)] for j in range(3)]
patterns += [[card[j][i] for i in range(3)] for j in range(3)]
patterns.append([card[i][i] for i in range(3)])
patterns.append([card[i][2-i] for i in range(3)] )

ok = False
N = int(input())
for _ in range(N):
    b = int(input())
    for pat in patterns:
        while b in pat:
            pat.remove(b)
            
for pat in patterns:
    if len(pat) == 0:
        print('Yes')
        sys.exit()

print('No')

Submission status: Accepted

Solution code:
mat=[list(map(int,input().split())) for i in range(3)]
N=int(input())
c=0
for n in range(N):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if mat[i][j]==b:
        mat[i][j]=0
for i in range(3):
  if mat[i][0]==0 and mat[i][1]==0 and mat[i][2]==0:
    c+=1
  elif mat[0][i]==0 and mat[1][i]==0 and mat[2][i]==0:
    c+=1
  elif mat[0][0]==0 and mat[1][1]==0 and mat[2][2]==0:
    c+=1
  elif mat[0][2]==0 and mat[1][1]==0 and mat[2][0]==0:
    c+=1

if c >= 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

for _ in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                g[i][j]=1

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

Submission status: Accepted

Solution code:
def bingo_search(CARD):
    for i in range(3):
        # 横一列そろったか否か
        if CARD[i][0] == '☓' and CARD[i][1] == '☓' and CARD[i][2] == '☓':
            return True

    for j in range(3):
        # 縦一列そろったか否か
        if CARD[0][j] == '☓' and CARD[1][j] == '☓' and CARD[2][j] == '☓':
            return True

    # ななめ一列そろったか否か
    if CARD[0][0] == '☓' and CARD[1][1] == '☓' and CARD[2][2] == '☓':
            return True

    # ななめ一列そろったか否か
    if CARD[0][2] == '☓' and CARD[1][1] == '☓' and CARD[2][0] == '☓':
            return True

    return False



A1 = list(input().split())
A2 = list(input().split())
A3 = list(input().split())
A = [A1, A2, A3]  #Bingoカードが完成
#print(A)

N = int(input())
for i in range(N):
    flag = False
    b = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = '☓'
                flag = True
                break
        if flag == True:
            break
#print(A)

if bingo_search(A):
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
A1 = input().split()
A2 = input().split()
A3 = input().split()

hit_example = [7,56,73,84,146,273,292,448]
b = 0
ans = "No"

N = int(input())
for i in range(N):
  x = int(input())
  if int(A1[0]) == x:
    b += 256
  elif int(A1[1]) == x:
    b += 128
  elif int(A1[2]) == x:
    b += 64
  elif int(A2[0]) == x:
    b += 32
  elif int(A2[1]) == x:
    b += 16
  elif int(A2[2]) == x:
    b += 8
  elif int(A3[0]) == x:
    b += 4
  elif int(A3[1]) == x:
    b += 2
  elif int(A3[2]) == x:
    b += 1

for val in hit_example:
  if val & b == val:
    ans = "Yes"
    break
    
print(ans)

Submission status: Accepted

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

for i in A2:
    A1.append(i)

for l in A3:
    A1.append(l)

N = int(input())

def my_index(l,a,default = False):
    if a in l:
        return l.index(a)
    else:
        return default

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

        
            
 
if A1[0]==A1[1]==A1[2]==0:
    print("Yes")
elif A1[3]==A1[4]==A1[5]==0:
    print("Yes")
elif A1[6]==A1[7]==A1[8]==0:
    print("Yes")
elif A1[0]==A1[3]==A1[6]==0:
    print("Yes")
elif A1[1]==A1[4]==A1[7]==0:
    print("Yes")
elif A1[2]==A1[5]==A1[8]==0:
    print("Yes")
elif A1[0]==A1[4]==A1[8]==0:
    print("Yes")
elif A1[2]==A1[4]==A1[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())
b=[int(input()) for i in range(n)]
count=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]==0 and a[i][1]==0 and a[i][2]==0:
        count += 1
    elif a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
        count += 1

if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    count +=1
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    count +=1

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

Submission status: Accepted

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

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

def Agetraw(j):
    Ans = [int(A[i][j]) for i in range(3)]
    return(Ans)

if (sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 
    or sum(Agetraw(0))==0 or sum(Agetraw(1))==0 or sum(Agetraw(2))==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")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
  a = []
  ans = "No"
  hit_examples = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
  for i in range(3):
    a.extend(list(map(int, input().split())))
  n = int(input())
  b = []
  for i in range(n):
    b.append(int(input()))
  for b_value in b:
    for i in range(len(a)):
      if b_value == a[i]:
        a[i] = -1

  for hit_example in hit_examples:
    cnt = 0
    for i in range(len(a)):
      if a[i] == -1 and i in hit_example:
        cnt += 1
      if cnt == 3:
        ans = "Yes"
        print(ans)
        return
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
li = []
b = []
cl = [[0]*3]*3
for i in range(3):
    l = list(map(int,input().split()))
    li.append(l)
N = int(input())
for i in range(N):
    b.append(int(input()))
ii = [0]*3
kk = [0]*3
for i in range(3):
    for k in range(3):
        if li[i][k] in b:
            ii[i] += 1
            kk[k] += 1
if (3 in ii) or (3 in kk):
    print("Yes")
elif ((li[0][0] in b) and(li[1][1] in b) and(li[2][2] in b)) or ((li[0][2] in b) and (li[1][1] in b) and (li[2][0] in b) ):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
t = [0] * 3
x = [0] * 3
y = [0] * 3
a=[]
for i in range(3):
    t[i], x[i], y[i] = map(int, input().split())
a.append(t)
a.append(x)
a.append(y)#二重のリストへ
n=int(input())
li=[input() for i in range(n)]
#メインコード
ctr=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in range(n):#それぞれのリストを探索
            if int(a[i][j])==int(li[k]):#intとintの比較なので注意
                ctr[i][j]+=1
if ctr[0][0]==ctr[0][1]==ctr[0][2]==1:
    print('Yes')
elif ctr[1][0]==ctr[1][1]==ctr[1][2]==1:
    print('Yes')
elif ctr[2][0]==ctr[2][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][0]==ctr[2][0]==1:
    print('Yes')
elif ctr[0][1]==ctr[1][1]==ctr[2][1]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][2]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][1]==ctr[2][0]==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def solve(A, n, b):
    for x in b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == x:
                    A[i][j] = -1
    for i in range(3):
        ok = True
        for j in range(3):
            if A[i][j] != -1:
                ok = False
                break
        if ok:
            return "Yes"
    for j in range(3):
        ok = True
        for i in range(3):
            if A[i][j] != -1:
                ok = False
                break
        if ok:
            return "Yes"
    ok = True
    for i in range(3):
        if A[i][i] != -1:
            ok = False
    if ok:
        return "Yes"
    ok = True
    for i in range(3):
        if A[2-i][i] != -1:
            ok = False
    if ok:
        return "Yes"
    return "No"

A = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
print(solve(A, n, b))

Submission status: Accepted

Solution code:
a=[]
for i in range(3):
  a.append(list(map(int,input().split())))
n=int(input())
b=[[0,0,0],[0,0,0],[0,0,0]]
for j in range(n):
  x=int(input())
  for k in range(3):
    for l in range(3):
      if x==a[k][l]:
        b[k][l]=1
if b[0]==[1,1,1] or b[1]==[1,1,1] or b[2]==[1,1,1] or [b[0][0],b[1][0],b[2][0]]==[1,1,1] or [b[0][1],b[1][1],b[2][1]]==[1,1,1] or [b[0][2],b[1][2],b[2][2]]==[1,1,1] or [b[0][0],b[1][1],b[2][2]]==[1,1,1] or [b[0][2],b[1][1],b[2][0]]==[1,1,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)]

bingo = False
for i in range(3):
    bingo = bingo or (A[i][0] in B and A[i][1] in B and A[i][2] in B)
    bingo = bingo or (A[0][i] in B and A[1][i] in B and A[2][i] in B)
bingo = bingo or (A[0][0] in B and A[1][1] in B and A[2][2] in B)
bingo = bingo or (A[0][2] in B and A[1][1] in B and A[2][0] in B)
print("Yes" if bingo else "No")

Submission status: Accepted

Solution code:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

card = [[0] * 3 for i in range(3)]
bingo = [[0] * 3 for i in range(3)]
flag = 0
for i in range(3):
    card[i][0],  card[i][1], card[i][2] = splitintinput()

N = intinput()
for i in range(N):
    b = intinput()
    for j in range(3):
        for k in range(3):
            if card[j][k] == b:
                bingo[j][k] = 1

for i in range(3):
    for j in range(3):
        if bingo[i][j] == 0:
            break
    else:
        flag = 1

for i in range(3):
    for j in range(3):
        if bingo[j][i] == 0:
            break
    else:
        flag = 1

for i in range(3):
    if bingo[i][i] == 0:
        break
else:
    flag = 1

for i in range(3):
    if bingo[i][2-i] == 0:
        break
else:
    flag = 1

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

Submission status: Accepted

Solution code:
def check(bingo):
    for j in range(3):#縦と横
        if bingo[j][0] == bingo[j][1] == bingo[j][2] == 0:
            return True
        elif bingo[0][j] == bingo[1][j] == bingo[2][j] == 0:
            return True
        else:
            pass
    #斜め
    if bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:
        return True
    elif bingo[2][0] == bingo[1][1] == bingo [0][2] == 0:
        return True
    else:
        return False
    
    

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



if check(bingo) == True:
    print("Yes")
else:
    print("No")