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:
a11,a12,a13=(int(x) for x in input().split())
a21,a22,a23=(int(x) for x in input().split())
a31,a32,a33=(int(x) for x in input().split())
n=int(input())
list=[]
for i in range(n):
	list.append(int(input()))
s=set(list)

def ch(a,b,c,s):
	k=0
	if a in s:
		if b in s:
			if c in s:
				k=1
	return k
co=0
co+=ch(a11,a12,a13,s)
co+=ch(a21,a22,a23,s)
co+=ch(a31,a32,a33,s)
co+=ch(a11,a21,a31,s)
co+=ch(a12,a22,a32,s)
co+=ch(a13,a23,a33,s)
co+=ch(a11,a22,a33,s)
co+=ch(a13,a22,a31,s)
if co>0:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
b1 = list(map(int, input().split()))
b2 = list(map(int, input().split()))
b3 = list(map(int, input().split()))
b4 = [b1[0],b2[0],b3[0]]
b5 = [b1[1],b2[1],b3[1]]
b6 = [b1[2],b2[2],b3[2]]
b7 = [b1[0],b2[1],b3[2]]
b8 = [b1[2],b2[1],b3[0]]

N = int(input())
num = []
for i in range(N):
  num += [int(input())]

if set(b1) <= set(num) or set(b2) <= set(num) or set(b3) <= set(num) or set(b4) <= set(num) or set(b5) <= set(num) or set(b6) <= set(num) or set(b7) <= set(num) or set(b8) <= set(num):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#B

a = [list(map(int,input().split())) for _ in range(3)]
c = [a[0][0],a[0][1],a[0][2],a[1][0],a[1][1],a[1][2],a[2][0],a[2][1],a[2][2]]
n = int(input())
b = [int(input()) for _ in range(n)]


for i in range(n):
    if b[i] in c:
        c[c.index(b[i])] = 0
#print(c)
p = sum(c[:3])*sum(c[3:6])*sum(c[6:9])*sum(c[::3])*sum(c[1::3])*sum(c[2::3])*(c[0]+c[4]+c[8])*(c[2]+c[4]+c[6])
if p == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
card = []
for i in range(3):
    card.append(list(map(int,input().split())))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if card[j][k] == b[i]:
                card[j][k] = 0
flag = 'No'
if card[0][0] == card[0][1] == card[0][2] == 0:
    flag = 'Yes'
if card[1][0] == card[1][1] == card[1][2] == 0:
    flag = 'Yes'
if card[2][0] == card[2][1] == card[2][2] == 0:
    flag = 'Yes'
if card[0][0] == card[1][0] == card[2][0] == 0:
    flag = 'Yes'
if card[0][1] == card[1][1] == card[2][1] == 0:
    flag = 'Yes'
if card[0][2] == card[1][2] == card[2][2] == 0:
    flag = 'Yes'
if card[0][0] == card[1][1] == card[2][2] == 0:
    flag = 'Yes'
if card[0][2] == card[1][1] == card[2][0] == 0:
    flag = 'Yes'
print(flag)

Submission status: Accepted

Solution code:
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
b = []
for j in range(N):
    b.append(int(input()))
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
Answer = []
for i in range(3):
    if A[i][0:3] == [0,0,0]:
        Answer.append('Yes')
        break
    elif A[0][i] == A[1][i] and A[1][i] == A[2][i]:
        Answer.append('Yes')
        break
    elif A[0][0] == A[1][1] and A[1][1] == A[2][2]:
        Answer.append('Yes')
        break
    elif A[0][2] == A[1][1] and A[1][1] == A[2][0]:
        Answer.append('Yes')
        break
if len(set(Answer)) == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
card = [0] * 3
for i in range(3):
    card[i] = [int(_) for _ in input().split()] 

n = int(input())
ls = [int(input()) for _ in range(n)]

for p in range(3):
    for q in range(3):
        if card[p][q] in ls:
            card[p][q] = -1
        else:
            continue

flag = [0, 0, 0]

for j in range(3):
    if card[j] == [-1, -1, -1]:
        flag[0] = 1

for k in range(3):
    if card[0][k] == card[1][k] == card[2][k] == -1:
        flag[1] = 1

if card[0][0] == card[1][1] == card[2][2] == -1:
    flag[2] = 1

if card[0][2] == card[1][1] == card[2][0] == -1:
    flag[2] = 1

if sum(flag) == 0:
    print("No")
elif sum(flag) > 0:
    print("Yes")

Submission status: Accepted

Solution code:
A0 = list(map(int, input().split(" ")))
A1 = list(map(int, input().split(" ")))
A2 = list(map(int, input().split(" ")))

A = [A0, A1, A2]

M = [
    [False, False, False],
    [False, False, False],
    [False, False, False],
]

N = int(input())
for _ in range(N):
    b = int(input())
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if col == b:
                M[i][j] = True

flag = False
for row in M:
    if all(row):
        flag = True

for i in range(3):
    col = []
    for j in range(3):
        col.append(M[j][i])

    if all(col):
        flag = True

dia0 = []
dia1 = []
for i in range(3):
    dia0.append(M[i][i])
    dia1.append(M[i][2 - i])

if all(dia0):
    flag = True

if all(dia1):
    flag = True

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

Submission status: Accepted

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

B1 = [0,0,0]
B2 = [0,0,0]
B3 = [0,0,0]

n = input()
N = int(n)

for i in range(N):
  B = input()
  b = int(B)
  if b == A1[0]:
    B1[0] = 1
  elif b == A1[1]:
    B1[1] = 1
  elif b == A1[2]:
    B1[2] = 1
  elif b == A2[0]:
    B2[0] = 1
  elif b == A2[1]:
    B2[1] = 1
  elif b == A2[2]:
    B2[2] = 1
  elif b == A3[0]:
    B3[0] = 1
  elif b == A3[1]:
    B3[1] = 1
  elif b == A3[2]:
    B3[2] = 1

#print(B1)
#print(B2)
#print(B3)
    
ans="No"

if B1[0]==1:
  if B1[1]==1:
    if B1[2]==1:
      ans = "Yes"
if B2[0]==1:
  if B2[1]==1:
    if B2[2]==1:
      ans = "Yes"
if B3[0]==1:
  if B3[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[0]==1:
    if B3[0]==1:
      ans = "Yes"
if B1[1]==1:
  if B2[1]==1:
    if B3[1]==1:
      ans = "Yes"
if B1[2]==1:
  if B2[2]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[2]==1:
  if B2[1]==1:
    if B3[0]==1:
      ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
#B - Bingo
import sys
a11,a12,a13=list(map(int,input().split()))
a21,a22,a23=list(map(int,input().split()))
a31,a32,a33=list(map(int,input().split()))
n = int(input())
card = []
card.append(a11)
card.append(a12)
card.append(a13)
card.append(a21)
card.append(a22)
card.append(a23)
card.append(a31)
card.append(a32)
card.append(a33)
x = 'x'
inputs = [input() for i in range(n)]
for j in inputs:
    if(int(j) in card):
        index = card.index(int(j))
        card[index] = 'x'
if(card[0] == x and card[1] == x and card[2] == x):
    print('Yes')
    sys.exit()
if(card[3] == x and card[4] == x and card[5] == x):
    print('Yes')
    sys.exit()
if(card[6] == x and card[7] == x and card[8] == x):
    print('Yes')
    sys.exit()
if(card[0] == x and card[3] == x and card[6] == x):
    print('Yes')
    sys.exit()
if(card[1] == x and card[4] == x and card[7] == x):
    print('Yes')
    sys.exit()
if(card[2] == x and card[5] == x and card[8] == x):
    print('Yes')
    sys.exit()
if(card[0] == x and card[4] == x and card[8] == x):
    print('Yes')
    sys.exit()
if(card[2] == x and card[4] == x and card[6] == x):
    print('Yes')
    sys.exit()
print('No')

Submission status: Accepted

Solution code:
import sys

A = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

*B, = map(int, input().split())
A[0][0] = B[0]
A[0][1] = B[1]
A[0][2] = B[2]

*B, = map(int, input().split())
A[1][0] = B[0]
A[1][1] = B[1]
A[1][2] = B[2]

*B, = map(int, input().split())
A[2][0] = B[0]
A[2][1] = B[1]
A[2][2] = B[2]

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


#斜めのチェック
if A[0][0]==-1 and A[1][1]==-1 and A[2][2]==-1:
    print("Yes")
    sys.exit()


if A[0][2]==-1 and A[1][1]==-1 and A[2][0]==-1:
    print("Yes")
    sys.exit()

#縦のチェック
for i in range(3):
    if A[0][i]==-1 and A[1][i]==-1 and A[2][i]==-1:
        print("Yes")
        sys.exit()

for i in range(3):
    if A[i][0]==-1 and A[i][1]==-1 and A[i][2]==-1:
        print("Yes")
        sys.exit()
print("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):
    b.append(int(input()))


for j in range(len(a)):
    for k in range(len(a)):
        for u in range(len(b)):
            if a[j][k] == b[u]:
                a[j][k] = 0


if (a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0) or (a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
    print("Yes")
    exit()
elif (a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0) or (a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0) or (a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0):
    print("Yes")
    exit()

for y in range(len(a)):
    if a[y].count(0) == 3:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A4 = [A1[0], A2[0], A3[0]]
A5 = [A1[1], A2[1], A3[1]]
A6 = [A1[2], A2[2], A3[2]]
A7 = [A1[0], A2[1], A3[2]]
A8 = [A1[2], A2[1], A3[0]]




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

flag = False
if len(b&set(A1)) == 3: flag = True
if len(b&set(A2)) == 3: flag = True
if len(b&set(A3)) == 3: flag = True
if len(b&set(A4)) == 3: flag = True
if len(b&set(A5)) == 3: flag = True
if len(b&set(A6)) == 3: flag = True
if len(b&set(A7)) == 3: flag = True
if len(b&set(A8)) == 3: flag = True
  
print('Yes' if flag else 'No')

Submission status: Accepted

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

def check():
    for b in b_n:
        for i in range(3):
            for j in range(3):
                if a[i][j] == b:
                    result[i][j] = 1
    yoko = [0]*3
    tate = [0]*3

    for i in range(3):
        for j in range(3):
            yoko[i] += result[i][j]
            tate[j] += result[i][j]
    for i in range(3):
        if yoko[i] == 3 or tate[i] == 3:
            print('Yes')
            return 0
    if result[0][0] + result[1][1] + result[2][2] ==3:
        print('Yes')
        return 0
    elif result[0][2] + result[1][1] + result[2][0] ==3:
        print('Yes')
        return 0
    print('No')
    return 0
check()

Submission status: Accepted

Solution code:
def bingo(C):
    if C[0]==C[1]==C[2] and C[0]==1:
        return True
    elif C[3]==C[4]==C[5] and C[3]==1:
        return True
    elif C[6]==C[7]==C[8] and C[6]==1:
        return True
    elif C[0]==C[3]==C[6] and C[0]==1:
        return True
    elif C[1]==C[4]==C[7] and C[1]==1:
        return True
    elif C[2]==C[5]==C[8] and C[2]==1:
        return True
    elif C[0]==C[4]==C[8] and C[0]==1:
        return True
    elif C[2]==C[4]==C[6] and C[2]==1:
        return True   
    else:
        return False

A=[]
for _ in range(3):
    x1,x2,x3=map(int, raw_input().split())
    A.append(x1)
    A.append(x2)
    A.append(x3)

B=[ 0 for _ in range(9) ]

N=input()

for _ in range(N):
    b=input()
    for i,x in enumerate(A):
        if b==x:
            B[i]=1
        

if bingo(B):
    print "Yes"
else:
    print "No"

Submission status: Accepted

Solution code:
ue = list(map(int, input().split()))
naka = list(map(int, input().split()))
sita = list(map(int, input().split()))
n = int(input())
b = [0] * n
for i in range(n):
    b[i] = int(input())

for i in b:
    ue = ['ok' if j == i else j for j in ue]
    naka = ['ok' if j == i else j for j in naka]
    sita = ['ok' if j == i else j for j in sita]

if ue[0]==ue[1]==ue[2] \
    or naka[0]==naka[1]==naka[2] \
    or sita[0]==sita[1]==sita[2] \
    or ue[0]==naka[0]==sita[0] \
    or ue[1]==naka[1]==sita[1] \
    or ue[2]==naka[2]==sita[2] \
    or ue[0]==naka[1]==sita[2] \
    or ue[2]==naka[1]==sita[0]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a_list = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

flag = False

for i in range(3):
    for i in range(3):
        if all([True if a_list[j][i] in b else False for j in range(3)]):
            if flag == False:
                print('Yes')
            flag = True
            break

if flag == False:
    for i in range(3):
        if all([True if a_list[i][j] in b else False for j in range(3)]):
            if flag == False:
                print('Yes')
            flag = True
            break

if flag == False:
    temp1 = [(0,0), (1,1), (2,2)]
    if all([True if a_list[i][j] in b else False for (i,j) in temp1]):
        print('Yes')
        flag = True

if flag == False:
    temp2 = [(0,2), (1,1), (2,0)]
    if all([True if a_list[i][j] in b else False for (i,j) in temp2]):
        print('Yes')
        flag = True
    
if flag == False:
    print('No')

Submission status: Accepted

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

aListCheck = []
for i in range(3):
  aListCheckRow = []
  for j in range(3):
    aListCheckRow.append(aList[i][j] in bList)
  aListCheck.append(aListCheckRow)

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

print('No')

Submission status: Accepted

Solution code:
N1=list(map(int,input().split()))
N2=list(map(int,input().split()))
N3=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
if b.count(N1[0])==b.count(N1[1])==b.count(N1[2])==1:
    print("Yes")
elif b.count(N2[0])==b.count(N2[1])==b.count(N2[2])==1 or b.count(N3[0])==b.count(N3[1])==b.count(N3[2])==1:
    print("Yes")
elif b.count(N1[0])==b.count(N2[0])==b.count(N3[0])==1 or  b.count(N1[1])==b.count(N2[1])==b.count(N3[1])==1 or b.count(N1[2])==b.count(N2[2])==b.count(N3[2])==1:
    print("Yes")
elif b.count(N1[0])==b.count(N2[1])==b.count(N3[2])==1 or b.count(N3[0])==b.count(N2[1])==b.count(N1[2])==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    YES="Yes"
    NO="No"

    A = []
    B = [[0]*3 for i in range(3)]
    for _ in range(3):
        l = list(map(int, input().split()))
        A.append(l)
    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] = 1
    for i in range(3):
        isBingoRow = True
        isBingoCol = True
        for j in range(3):
            isBingoRow = isBingoRow and (B[i][j] == 1)
            isBingoCol = isBingoCol and (B[j][i] == 1)
        if isBingoRow or isBingoCol:
            print(YES)
            return
    if B[0][0]==1 and B[1][1]==1 and B[2][2]==1:
        print(YES)
        return
    if B[0][2]==1 and B[1][1]==1 and B[2][0]==1:
        print(YES)
        return
    print(NO)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

    for b in B:
        for i in range(3):
            if b in A[i]:
                A[i][A[i].index(b)] = 0

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    from collections import defaultdict
    A = XLMIIS(3)

    exists = defaultdict(lambda : False)

    N = II()
    for _ in range(N):
        exists[II()] = True
    

    #上横、中横、下横
    for i in range(3):
        if exists[A[i][0]] and exists[A[i][1]] and exists[A[i][2]]:
            print('Yes')
            return
    #左縦、中縦、右縦
    for i in range(3):
        if exists[A[0][i]] and exists[A[1][i]] and exists[A[2][i]]:
            print('Yes')
            return
    #ナナメ
    if exists[A[0][0]] and exists[A[1][1]] and exists[A[2][2]]:
        print('Yes')
        return
    if exists[A[0][2]] and exists[A[1][1]] and exists[A[2][0]]:
        print('Yes')
        return
    print('No')
    return 
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))

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

for i in range(n):
  for j in range(3):
    if x[j] == a[i]:
      x[j] = 0
    if y[j] == a[i]:
      y[j] = 0
    if z[j] == a[i]:
      z[j] = 0
      
#print(x),print(y),print(z)
bingo = False

if max(x) == 0 or max(y) == 0 or max(z) == 0:
  bingo = True

for i in range(3):
  if x[i] == 0 and y[i] == 0 and z[i] == 0:
    bingo = True
    break

if x[0] == 0 and y[1] == 0 and z[2] == 0:
  bingo = True

if x[2] == 0 and y[1] == 0 and z[0] == 0:
  bingo = True

#print(bingo)
if bingo:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

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

check=[]
for i in range(3):
    for k,number in enumerate(a[i]):
        if number in b:
            check.append(1)
        else:
            check.append(0)

bingo_check=0
if check[0]==1:
    if check[1]==1 and check[2]==1:
        bingo_check=1
    elif check[3]==1 and check[6]==1:
        bingo_check=1
    elif check[4]==1 and check[8]==1:
        bingo_check=1
if check[1]==1:
    if check[4]==1 and check[7]==1:
        bingo_check=1
if check[2]==1:
    if check[5]==1 and check[8]==1:
        bingo_check=1
    elif check[4]==1 and check[6]==1:
        bingo_check=1
if check[3]==1:
    if check[4]==1 and check[5]==1:
        bingo_check=1

if check[6]==1:
    if check[7]==1 and check[8]==1:
        bingo_check=1


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

Submission status: Accepted

Solution code:
from itertools import product
data = [list(map(int, input().split())) for i in range(3)]
n = int(input())
bl = [int(input()) for _ in range(n)]
ok = [[0]*3 for _ in range(3)]

for b in bl:
    for i in range(3):
        for j in range(3):
            if data[i][j] == b:
                ok[i][j] = 1

# print(data)
# print(ok)
if sum(ok[0][:]) == 3 or sum(ok[1][:]) == 3 or sum(ok[2][:]) == 3 or (ok[0][0]+ok[1][0]+ok[2][0]) == 3 or (ok[0][1]+ok[1][1]+ok[2][1]) == 3 or (ok[0][2]+ok[1][2]+ok[2][2]) == 3 or (ok[0][0]+ok[1][1]+ok[2][2]) == 3 or (ok[0][2]+ok[1][1]+ok[2][0]) == 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A=list()
B=list()
C=list()
C=[[0 for i in range(3)]for j in range(3)]
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):
        if A[i][j] in B:
            C[i][j]=1
if C[0][0]*C[0][1]*C[0][2]==1:
    print("Yes")
elif C[1][0]*C[1][1]*C[1][2]==1:
    print("Yes")
elif C[2][0]*C[2][1]*C[2][2]==1:
    print("Yes")
elif C[0][0]*C[1][0]*C[2][0]==1:
    print("Yes")
elif C[0][1]*C[1][1]*C[2][1]==1:
    print("Yes")
elif C[0][2]*C[1][2]*C[2][2]==1:
    print("Yes")
elif C[0][0]*C[1][1]*C[2][2]==1:
    print("Yes")
elif C[0][2]*C[1][1]*C[2][0]==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np

bingo = np.zeros((3,3))
bin_bingo = np.zeros((3,3))

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



N = int(input())

for _ in range(N):
    num = int(input())
    bin_bingo = np.logical_or(bin_bingo, bingo == num)

# find bingo
lin1 = np.array([[True, True, True], [False, False, False], [False, False, False]])
lin2 = np.array([[False, False, False],[True, True, True], [False, False, False]])
lin3 = np.array([[False, False, False], [False, False, False], [True, True, True]])
col1 = lin1.T
col2 = lin2.T
col3 = lin3.T

sla1 = np.array([[True, False, False], [False, True, False], [False, False, True]])
sla2 = np.array([[False, False, True], [False, True, False], [True, False, False]])

def is_bingo(src, tmp):
    return (np.logical_and(src, tmp) == tmp).all()

flg = False
if is_bingo(bin_bingo, lin1):
    flg = True
elif is_bingo(bin_bingo, lin2):
    flg = True
elif is_bingo(bin_bingo, lin3):
    flg = True
elif is_bingo(bin_bingo, col1):
    flg = True
elif is_bingo(bin_bingo, col2):
    flg = True
elif is_bingo(bin_bingo, col3):
    flg = True
elif is_bingo(bin_bingo, sla1):
    flg = True
elif is_bingo(bin_bingo, sla2):
    flg = True

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

Submission status: Accepted

Solution code:
def resolve():
    A_list = []

    A_list.append(list(map(int, input().split())))
    A_list.append(list(map(int, input().split())))
    A_list.append(list(map(int, input().split())))


    N = int(input())

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

    for i in b_list:
        for j in range(len(A_list)):
            for k in range(len(A_list[j])):
                if A_list[j][k] == i:
                    A_list[j][k] = 0 


    if A_list[0][0] == 0 and A_list[0][1] == 0 and A_list[0][2] == 0:
        print("Yes")
        return

    if A_list[1][0] == 0 and A_list[1][1] == 0 and A_list[1][2] == 0:
        print("Yes")
        return

 
    if A_list[2][0] == 0 and A_list[2][1] == 0 and A_list[2][2] == 0:
        print("Yes")
        return

    if A_list[0][0] == 0 and A_list[1][0] == 0 and A_list[2][0] == 0:
        print("Yes")
        return

    if A_list[0][1] == 0 and A_list[1][1] == 0 and A_list[2][1] == 0:
        print("Yes")
        return

    if A_list[0][2] == 0 and A_list[1][2] == 0 and A_list[2][2] == 0:
        print("Yes")
        return

    if A_list[0][0] == 0 and A_list[1][1] == 0 and A_list[2][2] == 0:
        print("Yes")
        return

    if A_list[0][2] == 0 and A_list[1][1] == 0 and A_list[2][0] == 0:
        print("Yes")
        return


    print("No")
    return

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
bg=[]
num=[]
t=0
for i in range(3):
    a=input().split()
    for m in range(3):
        bg.append(int(a[m]))
n=int(input())
for k in range(n):
    num.append(int(input()))
ns=[0,0,0,0,0,0,0,0,0]
for j in range(9):
    if bg[j] in num:
        ns[j]=1
nm=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for l in nm:
    if ns[l[0]]+ns[l[1]]+ns[l[2]]==3:
        t=1
        break
if t==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

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

for b in bs:
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                bing[i][j]=1



def isbingo(board):
    for i in range(3):
        if sum(board[i])==3:
            return True
    for j in range(3):
        if sum([board[i][j] for i in range(3)])==3:
            return True
    if sum([board[0][0],board[1][1],board[2][2]])==3:
        return True
    if sum([board[0][2],board[1][1],board[2][0]])==3:
        return True
    return False
print('Yes'if isbingo(bing) else 'No')

Submission status: Accepted

Solution code:
a = []
for _ in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
card = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(3):
    for j in range(3):
        for x in b:
            if a[i][j] == x:
                card[i][j] = True
                break
l = [["00","01","02"],["10","11","12"],["20","21","22"],["00","10","20"],["01","11","21"],["02","12","22"],["00","11","22"],["02","11","20"]]
ans = False
for p in l:
    tmp = 0
    for q in p:
        i = int(q[0])
        j = int(q[1])
        if card[i][j]:
            tmp += 1
    if tmp == 3:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

list_ = set(a+b+c)
n = int(input())

a = np.array([a, b, c])

for _ in range(n):
  x = int(input())
  if x in list_:
    a = np.where(a==x,0,a)

if np.sum(a==0) < 3:
  print('No')
  quit()

for i in range(3):
  if sum(a[:,i]) == 0:
    print('Yes')
    quit()

for i in range(3):
  if sum(a[i,:]) == 0:
    print('Yes')
    quit()

if a[0,0]+a[1,1]+a[2,2] == 0 or a[0,2]+a[1,1]+a[2,0] == 0:
  print('Yes')
  quit()

print('No')

Submission status: Accepted

Solution code:
import sys
a = [0]*3
for i in range(3):
    a[i] = list(map(int,input().split()))
n = int(input())
b = [0 for _ in range(n)]
for k in range(n):
    b[k] = int(input())
flag = [[0 for u in range(3)]for r in range(3)]

for j in range(3):
    for l in range(3):
        for v in range(n):
            if(a[j][l] == b[v]):
                flag[j][l] = 1
                break

for h in range(3):
    if(sum(flag[h]) == 3):
      print("Yes")
      sys.exit()

if(flag[0][0] + flag[1][1] + flag[2][2] == 3 or flag[0][2] + flag[1][1] + flag[2][0] == 3):
    print("Yes")
    sys.exit()

if(flag[0][0] + flag[1][0] + flag[2][0] == 3 or flag[0][1] + flag[1][1] + flag[2][1] == 3 or flag[0][2] + flag[1][2] + flag[2][2] == 3):
    print("Yes")
    sys.exit()
print("No")

Submission status: Accepted

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

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


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

Submission status: Accepted

Solution code:
A=[input().split() for i in range(3)]
N=int(input())
b=[0]*N
for i in range(N):
    b[i]=int(input())
    
for i in range(3):
    for j in range(3):
        for k in range(N):
            if int(A[i][j])-b[k]==0:
                A[i][j]=0

flag=0    
if A[0][0]==0 and A[0][1]==0 and A[0][2]==0:
    flag+=1
elif A[0][0]==0 and A[1][0]==0 and A[2][0]==0:
    flag+=1
elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    flag+=1
elif A[0][1]==0 and A[1][1]==0 and A[2][1]==0:
    flag+=1
elif A[0][2]==0 and A[1][2]==0 and A[2][2]==0:
    flag+=1
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    flag+=1
elif A[1][0]==0 and A[1][1]==0 and A[1][2]==0:
    flag+=1
elif A[2][0]==0 and A[2][1]==0 and A[2][2]==0:
    flag+=1

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

Submission status: Accepted

Solution code:
def func(x):
  for i in range(3):
    if len([x[i][j] for j in [0,1,2] if x[i][j]])==3:
      return True
    elif len([x[j][i] for j in [0,1,2] if x[j][i]])==3:
      return True
  if len([x[i][i] for i in [0,1,2] if x[i][i]])==3:
    return True
  elif len([x[i][j] for i,j in zip([0,1,2],[2,1,0]) if x[i][j]])==3:
    return True
  else:
    False
    
x = [[False]*3 for i in range(3)]
A = []
for _ in range(3): A += list(map(int, input().split()))
N = int(input())
for i in range(N):
  b = int(input())
  if b in A:
    i = A.index(b)
    j,k = i%3, i//3
    x[k][j] = True
  if func(x):
    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())
for i in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0

temp = False
temp = temp or (A[0] + A[1] + A[2]) == 0
temp = temp or (A[3] + A[4] + A[5]) == 0
temp = temp or (A[6] + A[7] + A[8]) == 0
temp = temp or (A[0] + A[3] + A[6]) == 0
temp = temp or (A[1] + A[4] + A[7]) == 0
temp = temp or (A[2] + A[5] + A[8]) == 0
temp = temp or (A[0] + A[4] + A[8]) == 0
temp = temp or (A[2] + A[4] + A[6]) == 0

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

Submission status: Accepted

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

for b in B:
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                A[row][col] = 0

cond = [
    A[0][0] == A[0][1] and A[0][1] == A[0][2],
    A[1][0] == A[1][1] and A[1][1] == A[1][2],
    A[2][0] == A[2][1] and A[2][1] == A[2][2],
    A[0][0] == A[1][0] and A[1][0] == A[2][0],
    A[0][1] == A[1][1] and A[1][1] == A[2][1],
    A[0][2] == A[1][2] and A[1][2] == A[2][2],
    A[0][0] == A[1][1] and A[1][1] == A[2][2],
    A[0][2] == A[1][1] and A[1][1] == A[2][0]
]
print('Yes' if any(cond) else 'No')