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:
bingo = []
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
matched = [[False for _ in range(3)] for _ in range(3)]
N = int(input())
for n in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                matched[i][j] = True
is_bingo = False
if matched[0][0] and matched[1][1] and matched[2][2]:
    is_bingo = True
if matched[0][2] and matched[1][1] and matched[2][0]:
    is_bingo = True
if matched[0][0] and matched[0][1] and matched[0][2]:
    is_bingo = True
if matched[1][0] and matched[1][1] and matched[1][2]:
    is_bingo = True
if matched[2][0] and matched[2][1] and matched[2][2]:
    is_bingo = True
if matched[0][0] and matched[1][0] and matched[2][0]:
    is_bingo = True
if matched[0][1] and matched[1][1] and matched[2][1]:
    is_bingo = True
if matched[0][2] and matched[1][2] and matched[2][2]:
    is_bingo = True
if is_bingo:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def determin_bingo(row_list):
    for num in row_list:
        if num != 0:
            return False
    return True

g=0
a_list=[]
while g<3:
    a_element=input()
    a_element=a_element.split()
    a_list.append(list(map(int, a_element)))
    g+=1

h=0
b_list=[]
n=int(input())
while h<n:
    b_list.append(int(input()))
    h+=1
    
a_list.extend([
    [a_list[0][0], a_list[1][0], a_list[2][0]],
    [a_list[0][2], a_list[1][2], a_list[2][2]],
    [a_list[0][0], a_list[1][1], a_list[2][2]],
    [a_list[0][2], a_list[1][1], a_list[2][0]]
])

f=0
for a in a_list:
    for b in b_list:
        if b in a:
            a_list[f][a.index(b)]=0
    f+=1


result='No'

for a in a_list:
    if determin_bingo(a):
        result='Yes'
        break

print(result)

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 i in range(3):
    A.append([A[0][i] ,A[1][i] ,A[2][i]])
A.append([A[0][0] ,A[1][1] ,A[2][2]])
A.append([A[0][2] ,A[1][1] ,A[2][0]])
#print(A)
cnt1 = 0
for i in range(8):
    cnt = 0
    for j in range(3):
        for k in range(N):
            if A[i][j] == B[k]:
                cnt += 1
            if cnt == 3:
                cnt1 = 100
if cnt1 != 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
al = [input().split() for _ in range(3)]
n = int(input())
for _ in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if al[i][j]==b:
                al[i][j] = "0"

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

Submission status: Accepted

Solution code:
bingo = [list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))]
N = int(input())
numbers = []
zeros = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
    numbers.append(int(input()))

for i in numbers:
    for y, row in enumerate(bingo):
        for x, elem in enumerate(row):
            if bingo[x][y] == i:
                zeros[x][y] = 1
ans = False
for i in range(3):
    if zeros[i][0] == 1 and zeros[i][1] == 1 and zeros[i][2] == 1:
        ans = True
    if zeros[0][i] == 1 and zeros[1][i] == 1 and zeros[2][i] == 1:
        ans = True
if zeros[0][0] == 1 and zeros[1][1] == 1 and zeros[2][2] == 1:
    ans = True
if zeros[0][2] == 1 and zeros[1][1] == 1 and zeros[2][0] == 1:
    ans = True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
aList = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
bList = [int(input()) for _ in range(n)]
for i in range(3):
    for j in range(3):
        if aList[i][j] in bList:
            aList[i][j] = 0
flag = False
if [0, 0, 0] in aList:
    flag = True
else:
    for i in range(3):
        if aList[0][i] == aList[1][i] == aList[2][i] == 0:
            flag = True
if not flag and aList[1][1] == 0:
    if aList[0][0] == aList[2][2] == 0 or aList[2][0] == aList[0][2] == 0:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for y in range(3):
    for b in b_list:
        if b in a_list[y]:
            index = a_list[y].index(b)
            a_list[y][index] = -1

is_bingo = False
for y in range(3):
    if sum(a_list[y]) == -3:
        is_bingo = True
        break

for x in range(3):
    if a_list[0][x]+a_list[1][x]+a_list[2][x] == -3:
        is_bingo = True
        break

if a_list[0][0]+a_list[1][1]+a_list[2][2] == -3:
    is_bingo = True
elif a_list[0][2]+a_list[1][1]+a_list[2][0] == -3:
    is_bingo = True


if is_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()))
N = int(input())
B = []
for i in range(N):
    b = int(input())
    B.append(b)

for i in B:
    for j in range(3):
        if i == A1[j]:
            A1[j] = 0
        elif i == A2[j]:
            A2[j] = 0
        elif i == A3[j]:
            A3[j] = 0
        
if A1 == [0,0,0] or A2 == [0,0,0] or A3 == [0,0,0]:
    print("Yes")
elif A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
    print("Yes")
elif A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
     print("Yes")
elif A1[0] == 0 and A2[0] == 0 and A3[0] == 0:
    print("Yes")
elif A1[1] == 0 and A2[1] == 0 and A3[1] == 0:
    print("Yes")
elif A1[2] == 0 and A2[2] == 0 and A3[2] == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np

bingo_list = [list(map(int, input().strip().split())) for i in range(3)]
n = int(input())
num_list = [int(input()) for i in range(n)]

bingo_ar = np.array(bingo_list)
out_ar = np.zeros((3, 3), dtype=int)

for i in range(3):
    for j in range(3):
        if bingo_ar[i, j] in num_list:
            out_ar[i, j] = 1

out = 'No'

if max(max(np.sum(out_ar, 0, dtype=int)), max(np.sum(out_ar, 1, dtype=int)), out_ar[0, 0] +
       out_ar[1, 1] + out_ar[2, 2], out_ar[2, 0] +
       out_ar[1, 1] + out_ar[0, 2]) == 3:
    out = 'Yes'

print(out)

Submission status: Accepted

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

n=int(input())
b = [(input()) for i in range(n)]
s=[]
for i in range(n):
  for j in range(3):
    if b[i] in a[j]:
      k=a[j].index(b[i])
      s.append([j,k])
      if [j,0] in s and [j,1] in s and [j,2] in s:
        print("Yes")
        break
      elif [0,k] in s and [1,k] in s and [2,k] in s:
        print("Yes")
        break
      elif j==k:
        if [0,0] in s and [1,1] in s and [2,2] in s:
          print("Yes")
          break
        elif [0,2] in s and [1,1] in s and [2,0] in s:
          print("Yes")
          break
  else:
    continue
  break
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)]
ans = [[0,0,0] for i in range(3)]



for i in range(3):
  for j in range(3):
    for k in b:
      if(a[i][j] == k):
        ans[i][j] = 1
        break
if(ans[0][0] + ans[0][1] + ans[0][2] == 3 or ans[0][0] + ans[1][0] + ans[2][0] == 3 or ans[1][0] + ans[1][1] + ans[1][2] == 3 or ans[2][0] + ans[2][1] + ans[2][2] == 3 or ans[0][2] + ans[1][2] + ans[2][2] == 3 or ans[0][1] + ans[1][1] + ans[2][1] == 3 or ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
r1 = list(map(int,input().split()))
r2 = list(map(int,input().split()))
r3 = list(map(int,input().split()))
c1 = [r1[0],r2[0],r3[0]]
c2 = [r1[1],r2[1],r3[1]]
c3 = [r1[2],r2[2],r3[2]]
d1 = [r1[0],r2[1],r3[2]]
d2 = [r1[2],r2[1],r3[0]]
l = [r1,r2,r3,c1,c2,c3,d1,d2]

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

def bingo(num):
    for i in l:
        try:
            i.remove(num)
        except:
            pass

        for j in l:
            if j == []:
                return True
    return False

for i in b:
    if bingo(i):
        print("Yes")
        exit()
else:
    print("No")

Submission status: Accepted

Solution code:
import itertools
def main():
    A=[list(map(int,input().split())) for _ in range(3)]
    n=int(input())
    B=list(int(input()) for _ in range(n))
    B=sorted(B)
    C=itertools.combinations(B,3)
    if n<3:
        print('No')
        return
    
    ans=[]
    ans.append(sorted(A[0]))
    ans.append(sorted(A[1]))
    ans.append(sorted(A[2]))
    ans.append(sorted([a[0] for a in A]))
    ans.append(sorted([a[1] for a in A]))
    ans.append(sorted([a[2] for a in A]))
    ans.append(sorted([A[0][0],A[1][1],A[2][2]]))
    ans.append(sorted([A[0][2],A[1][1],A[2][0]]))
    for c in C:
        if list(c) in ans:
            print('Yes')
            return
    print('No')
    
main()

Submission status: Accepted

Solution code:
line1 = input().split(" ")
line2 = input().split(" ")
line3 = input().split(" ")

result1 = []
result2 = []
result3 = []

for i in range(3):
  result1.append("0")
  result2.append("0")
  result3.append("0")

call_sum = int(input())

for j in range(call_sum):
  call_num = int(input())
  for i in range(3):
    if call_num == int(line1[i]):
      result1[i] = "1"
      break
    if call_num == int(line2[i]):
      result2[i] = "1"
      break
    if call_num == int(line3[i]):
      result3[i] = "1"
      break
while(1):
  if result1[0] == result1[1] == result1[2] == "1" or result2[0] == result2[1] == result2[2] == "1" or result3[0] == result3[1] == result3[2] == "1":
    print("Yes")
    break
  elif result1[0] == result2[1] == result3[2] == "1" or result1[2] == result2[1] == result3[0] == "1":
    print("Yes")
    break
  for j in range(3):
    end_flg = False
    if result1[j] == result2[j] == result3[j] == "1":
      print("Yes")
      end_flg = True
      break
  if end_flg:
    break
  print("No")
  break

Submission status: Accepted

Solution code:
X = []
Y = []
Z = []
for i in range(3):
    x, y, z = map(int, input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)
N = int(input())

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

for i in range(N):
    
    if X[0] == b[i]:
        X[0] = 'OK'
    if X[1] == b[i]:
        X[1] = 'OK'
    if X[2] == b[i]:
        X[2] = 'OK'
    if Y[0] == b[i]:
        Y[0] = 'OK'
    if Y[1] == b[i]:
        Y[1] = 'OK'
    if Y[2] == b[i]:
        Y[2] = 'OK'
    if Z[0] == b[i]:
        Z[0] = 'OK'
    if Z[1] == b[i]:
        Z[1] = 'OK'
    if Z[2] == b[i]:
        Z[2] = 'OK'

if (X[0] == X[1] == X[2]
    or Y[0] == Y[1] == Y[2]
    or Z[0] == Z[1] == Z[2]
    or X[0] == Y[0] == Z[0]
    or X[1] == Y[1] == Z[1]
    or X[2] == Y[2] == Z[2]
    or X[0] == Y[1] == Z[2]
    or X[2] == Y[1] == Z[0]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = []
check = []

for i in range(3):
	a, b, c = map(int, input().split())
	A.append(a)
	check.append(False)
	A.append(b)
	check.append(False)
	A.append(c)
	check.append(False)

N = int(input())

for i in range(N):
	b = int(input())
	for j in range(len(A)):
		if A[j] == b:
			check[j] = True

c = False
for i in range(3):
	if check[i*3] and check[i*3+1] and check[i*3+2]:
		c = True

for i in range(3):
	if check[i] and check[i+3] and check[i+6]:
		c = True

if check[0] and check[4] and check[8]:
	c = True

if check[2] and check[4] and check[6]:
	c = True

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

Submission status: Accepted

Solution code:
import itertools

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

A = list(itertools.chain.from_iterable(A))

X = []

for c in b:
    if c in A:
        X.append(A.index(c))

if (0 in X and 1 in X and 2 in X) or \
        (3 in X and 4 in X and 5 in X) or \
        (6 in X and 7 in X and 8 in X) or \
        (0 in X and 3 in X and 6 in X) or \
        (1 in X and 4 in X and 7 in X) or \
        (2 in X and 5 in X and 8 in X) or \
        (0 in X and 4 in X and 8 in X) or \
        (2 in X and 4 in X and 6 in X):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np


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

    result = np.zeros((3, 3))

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

    for i in range(3):
        if all(result[i, :]):
            print('Yes')
            exit(0)
    for i in range(3):
        if all(result[:, i]):
            print('Yes')
            exit(0)
    if all([result[0, 0], result[1, 1], result[2, 2]]):
        print('Yes')
        exit(0)
    if all([result[0, 2], result[1, 1], result[2, 0]]):
        print('Yes')
        exit(0)
    print('No')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# 横チェック
def yoko(bingo,b):
    i,j = 0,0
    isbingo = False
    for i in [0,1,2]:
        for j in [0,1,2]:
            if bingo[i][j] in b:
                if j==2:
                    return True
            else:
                break
    return False

def tate(bingo,b):
    i,j = 0,0
    isbingo = False
    for j in [0,1,2]:
        for i in [0,1,2]:
            if bingo[i][j] in b:
                if i==2:
                    return True
            else:
                break
    return False

def naname(bingo,b):
    i,j = 0,0
    isbingo = False
    for i,j in zip([0,1,2],[0,1,2]):
        if bingo[i][j] in b:
            if i==2:
                return True
        else:
            break
    for i,j in zip([0,1,2],[2,1,0]):
        if bingo[i][j] in b:
            if i==2:
                return True
        else:
        	break
    return False

row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))
n = int(input())
i = 0
b = []
while(i < n):
  b.append(int(input()))
  i += 1

bingo = []
bingo.append(row1)
bingo.append(row2)
bingo.append(row3)
if (tate(bingo,b))|(yoko(bingo,b))|(naname(bingo,b)):
    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 j 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

col1 = A[0][0]+A[1][0]+A[2][0]
col2 = A[0][1]+A[1][1]+A[2][1]
col3 = A[0][2]+A[1][2]+A[2][2]
dig1 = A[0][0]+A[1][1]+A[2][2]
dig2 = A[2][0]+A[1][1]+A[0][2]
if sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 or col1==0 or col2==0 or col3==0 or dig1==0 or dig2==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a1=list(map(int,input().split(" ")))
a2=list(map(int,input().split(" ")))
a3=list(map(int,input().split(" ")))
N=int(input())
b=[]

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

allnum=[]
allnum.append(a1)
allnum.append(a2)
allnum.append(a3)


bingo=[[0,0,0],[0,0,0],[0,0,0]]

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

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

if(bingo[2][0] and bingo[1][1] and bingo[0][2]):
    print("Yes")
    exit()
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()))
maru=111
flag=0
n=int(input())
for k in range(0,n):
    e=int(input())
    for i in range(0,3):    
        if e==a[i]:
            a[i]=maru
        if e==b[i]:
            b[i]=maru
        if e==c[i]:
            c[i]=maru

for j in range(0,3):
    if a[j]==b[j] and b[j]==c[j]:
        if c[j]==maru:
            flag=1
            
if a[0]==a[1] and a[1]==a[2]:
    if a[0]==maru:
        flag=1
if b[0]==b[1] and b[1]==b[2]:
    if b[0]==maru:
        flag=1
if c[0]==c[1] and c[1]==c[2]:
    if c[0]==maru:
        flag=1

if a[0]==b[1] and b[1]==c[2]:
    if c[2]==maru:
        flag=1

if a[2]==b[1] and b[1]==c[0]:
    if c[0]==maru:
        flag=1



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

Submission status: Accepted

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

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

ls = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 4, 8],
    [2, 4, 6],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8]
]

N = int(input())

result = "No"

for i in range(N):
    b = int(input())
    if b in card:
        check[card.index(b)] = True
    for e in ls:
        if all([check[el] for el in e]):
            result = "Yes"
            break

print(result)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

A_list = []
for i in range(3):
    A, B, C = map(int, input().split())
    A_list.append([A, B, C])
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A_list[j][k] == b:
                A_list[j][k] = 0

A_array = np.array(A_list)

ans = "No"
if 0 in np.sum(A_array, axis=0):
    ans = "Yes"

if 0 in np.sum(A_array, axis=1):
    ans = "Yes"

if A_array[0][0] + A_array[1][1] + A_array[2][2] == 0:
    ans = "Yes"

if A_array[0][2] + A_array[1][1] + A_array[2][0] == 0:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
def main():
    lst = []
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    n = int(input())


    for _ in range(n):
        temp = int(input())
        if temp in lst:
            i = lst.index(temp)
            lst[i] = False
    answer = "No"
    if (all((not lst[0],not lst[1],not lst[2]))) or (all(( not lst[3],not lst[4],not lst[5]))) or (all((not lst[6],not lst[7],not lst[8]))):
        answer = "Yes"
    if (all((not lst[0],not lst[3], not lst[6]))) or (all((not lst[1],not lst[4],not lst[7]))) or (all((not lst[2],not lst[5],not lst[8]))):
        answer = "Yes"
    if (all((not lst[0],not lst[4],not lst[8]))) or (all((not lst[2],not lst[4],not lst[6]))):
        answer = "Yes"
    print(answer)










if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

for b in Bn:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

ans = False
if A[0][0] == A[1][1] == A[2][2] == 0:
    ans = True

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

# col
for i in range(3):
    cnt = 0
    for j in range(3):
        if A[j][i] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

# row
for i in range(3):
    cnt = 0
    for j in range(3):
        if A[i][j] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

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

Submission status: Accepted

Solution code:
import math

def main():
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))
    A3 = list(map(int, input().split()))
    n = int(input())
    B = [int(input()) for _ in range(n)]

    bingo = [[0]*3]+[[0]*3]+[[0]*3]

    A = [A1, A2, A3]
    row_sum1 = 0
    row_sum2 = 0
    row_sum3 = 0
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if B[i]==A[j][k]:
                    bingo[j][k] = 1
    for i in range(len(bingo)):
        if sum(bingo[i])==3:
            print('Yes')
            return
        row_sum1 += bingo[i][0]
        row_sum2 += bingo[i][1]
        row_sum3 += bingo[i][2]

    if bingo[0][0] == bingo[1][1] == bingo[2][2] == 1 or bingo[0][2] == bingo[1][1] == bingo[2][0] == 1:
        print('Yes')
        return
    if row_sum1==3 or row_sum2==3 or row_sum3==3:
        print('Yes')
        return
    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def inputs(): return [int(x) for x in input().split()]
a1 = inputs()
a2= inputs()
a3=inputs()
n = int(input())
N = []
for i in range(n):
  N.append(int(input()))
cnt= [0]*8
for j in range(3):
  if a1[j] in N:
    cnt[0] +=1
for j in range(3):
  if a2[j] in N:
    cnt[1] +=1
for j in range(3):
  if a3[j] in N:
    cnt[2] +=1
for j in range(3):
  if a1[j] in N and a2[j] in N and a3[j] in N:
    cnt[3+j] +=3
if a1[0] in N and a2[1] in N and a3[2] in N:
  cnt[6] +=3
if a1[2] in N and a2[1] in N and a3[0] in N:
  cnt[7] +=3
if 3 in cnt:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# 3 * 3 の配列ができる
bingoArr = [list(map(int, list(input().split()))) for i in range(3)]

# 試行回数
N = int(input())

# ターゲット
target = [int(input()) for i in range(N)]

# [84 97 66]
for i in range(0, len(bingoArr)):
    for y in range(0, len(bingoArr[i])):
        for t in target:
            if bingoArr[i][y] == t:
                bingoArr[i][y] = -1
res = 'No'
if bingoArr[0][0] == -1 and bingoArr[0][1] == -1 and bingoArr[0][2] == -1:
    res = 'Yes'

if bingoArr[1][0] == -1 and bingoArr[1][1] == -1 and bingoArr[1][2] == -1:
    res = 'Yes'

if bingoArr[2][0] == -1 and bingoArr[2][1] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][0] == -1 and bingoArr[1][0] == -1 and bingoArr[2][0] == -1:
    res = 'Yes'

if bingoArr[0][1] == -1 and bingoArr[1][1] == -1 and bingoArr[2][1] == -1:
    res = 'Yes'

if bingoArr[0][2] == -1 and bingoArr[1][2] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][0] == -1 and bingoArr[1][1] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][2] == -1 and bingoArr[1][1] == -1 and bingoArr[2][0] == -1:
    res = 'Yes'

print(res)

Submission status: Accepted

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

def bingo():
    tA = A
    for i in range(S):
        for j in range(S):
            if(tA[i][j] in b):
                tA[i][j] = True
            else:
                tA[i][j] = False

    TA = list(zip(*tA))
    for i in range(S):
        if(tA[i].count(True)==S):return True
        if(TA[i].count(True)==S):return True
    
    if([tA[i][i] for i in range(S)].count(True)==S): return True
    if([tA[i][S-i-1] for i in range(S)].count(True)==S): return True
    return False

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

Submission status: Accepted

Solution code:
import numpy as np

A = [ list(map(int,input().split(" "))) for i in range(3)]
N = int(input())
X = np.ones((3,3))
for num in range(N):
  b_num = int(input())
  for i in range(3):
    for j in range(3):
      X[i,j] = X[i,j] * ( A[i][j] - b_num )
      
sum = 1
for n in range(3):
  sum = sum * ( X[n,0]**2 + X[n,1]**2 + X[n,2]**2 )
  sum = sum * ( X[0,n]**2 + X[1,n]**2 + X[2,n]**2 )
sum = sum * ( X[0,0]**2 + X[1,1]**2 + X[2,2]**2 )
sum = sum * ( X[0,2]**2 + X[1,1]**2 + X[2,0]**2 )

if sum == 0:
  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()]
n=int(input())
b=set()
for c in range(n):
    b.add(int(input()))
t=list(range(8))
t[1]=set(a1)
t[2]=set(a2)
t[3]=set(a3)
t[4]={a1[0],a2[0],a3[0]}
t[5]={a1[1],a2[1],a3[1]}
t[6]={a1[2],a2[2],a3[2]}
t[7]={a1[0],a2[1],a3[2]}
t[0]={a1[2],a2[1],a3[0]}

k=0
for c in range(8):
    if t[c]<=b:
        k=1
if k==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import itertools

a=[]

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

temp=[]
temp.append((a[0][0],a[0][1],a[0][2]))
temp.append((a[1][0],a[1][1],a[1][2]))
temp.append((a[2][0],a[2][1],a[2][2]))
temp.append((a[0][0],a[1][0],a[2][0]))
temp.append((a[0][1],a[1][1],a[2][1]))
temp.append((a[0][2],a[1][2],a[2][2]))
temp.append((a[0][0],a[1][1],a[2][2]))
temp.append((a[0][2],a[1][1],a[2][0]))

n=int(input())

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

res=list(itertools.permutations(num,3))
flag=0
for i in range(len(temp)):
    for j in range(len(res)):
        if temp[i] == res[j]:
            flag=1
            break
        else:
            continue

if flag == 1:
    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 = []
for i in range(N):
  b += [int(input())]
S1 = {A[0], A[1], A[2]}
S2 = {A[3], A[4], A[5]}
S3 = {A[6], A[7], A[8]}
S4 = {A[0], A[3], A[6]}
S5 = {A[1], A[4], A[7]}
S6 = {A[2], A[5], A[8]}
S7 = {A[0], A[4], A[8]}
S8 = {A[2], A[4], A[6]}
flg = 0
if S1 < set(b): flg = 1
if S2 < set(b): flg = 1
if S3 < set(b): flg = 1
if S4 < set(b): flg = 1
if S5 < set(b): flg = 1
if S6 < set(b): flg = 1
if S7 < set(b): flg = 1
if S8 < set(b): flg = 1
print('Yes' if flg == 1 else 'No')

Submission status: Accepted

Solution code:
yoko1 = list(map(int,input().split()))
yoko2 = list(map(int,input().split()))
yoko3 = list(map(int,input().split()))
n = int(input())
bingono = []
for _ in range(n):
    bingono.append(int(input()))
for num in bingono:
    for i in range(0,3):
        if yoko1[i] == num:
            yoko1[i] = True
        if yoko2[i] == num:
            yoko2[i] = True
        if yoko3[i] == num:
            yoko3[i] = True
if yoko1.count(True)==3 or yoko2.count(True)==3 or yoko3.count(True)==3:
    print("Yes")
    exit()
for i in range(0,3):
    if yoko1[i] == True and yoko2[i] == True and yoko3[i] == True:
        print("Yes")
        exit()
if yoko1[0] == True and yoko2[1] == True and yoko3[2] == True:
    print("Yes")
    exit()
if yoko1[2] == True and yoko2[1] == True and yoko3[0] == True:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:


bingo = []
for count in range(0,3):
    A = list(map(int,input().split()))
    bingo.append(A)

bingo1 = [0] * 3
bingo2 = [0] * 3
bingo3 = [0] * 3
N = int(input())

for count in range(0,N):
    inp = int(input())
    for count3 in range(3):
        bi = bingo[count3]
        for count2 in range(3):
            if bi[count2] == inp:
                if count3 == 0:
                    bingo1[count2] = 1
                if count3 == 1:
                    bingo2[count2] = 1
                if count3 ==2 :
                    bingo3[count2] = 1
bingF = False
#bingo判定
for count in range(3):
    #縦
    if bingo1[count] == 1 and bingo2[count] == 1 and bingo3[count] == 1:
        bingF = True

#横
if bingo1[0] == 1 and bingo1[1] == 1 and bingo1[2] == 1:
    bingF = True
if bingo2[0] == 1 and bingo2[1] == 1 and bingo2[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo3[1] == 1 and bingo3[2] == 1:
    bingF = True

#斜め
if bingo1[0] == 1 and bingo2[1] == 1 and bingo3[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo2[1] == 1 and bingo1[2] == 1:
    bingF = True

if bingF == False:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
A_list = []

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

for i in range(3):
  a, b, c = map(int, input().split())
  A_list.append(a)
  A_list.append(b)
  A_list.append(c)

N = int(input())
flag=True

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

  tmp = my_index(A_list, num, -100)
  if tmp != -100:
    A_list[tmp] = -1
  
  if ((A_list[0] == A_list[3]) and (A_list[0] == A_list[6]) and (A_list[3] == A_list[6])) or \
     ((A_list[1] == A_list[4]) and (A_list[1] == A_list[7]) and (A_list[4] == A_list[7])) or \
     ((A_list[2] == A_list[5]) and (A_list[2] == A_list[8]) and (A_list[5] == A_list[8])) or \
     ((A_list[0] == A_list[4]) and (A_list[0] == A_list[8]) and (A_list[4] == A_list[8])) or \
     ((A_list[2] == A_list[4]) and (A_list[2] == A_list[6]) and (A_list[4] == A_list[6])) or \
     ((A_list[0] == A_list[1]) and (A_list[0] == A_list[2]) and (A_list[1] == A_list[2])) or \
     ((A_list[3] == A_list[4]) and (A_list[3] == A_list[5]) and (A_list[4] == A_list[5])) or \
     ((A_list[6] == A_list[7]) and (A_list[6] == A_list[8]) and (A_list[7] == A_list[8])):
    print("Yes")
    flag=False
    break

if flag:
  print("No")

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
n = int(input())

ins = []
for i in range(n):
    b = int(input())
    if b in a:
        ins.append(a.index(b))

okp = [(0,1,2), (3,4,5), (6,7,8) ,(0,3,6), (1,4,7), (2,5 ,8), (0,4,8), (2,4,6)]
f = "No"
for x, y, z in okp:
    if x in ins and y in ins and z in ins:
        f = "Yes"
        break

print(f)