Problem:


Score : 200 points

Problem Statement

We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.

The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints

All values in input are integers.

1 \leq A_{i, j} \leq 100

A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

A_{1, 1} A_{1, 2} A_{1, 3}
A_{2, 1} A_{2, 2} A_{2, 3}
A_{3, 1} A_{3, 2} A_{3, 3}
N
b_1
\vdots
b_N

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.



Sample input:
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30


Sample output:
Yes

Submission status: Accepted

Solution code:
import sys
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))
lis3 = list(map(int,input().split()))
n = int(input())
b_lis = [int(input()) for _ in range(n)]
for i,l1 in enumerate(lis1):   
    if l1 in b_lis:
        lis1[i] = 0
for j,l2 in enumerate(lis2):   
    if l2 in b_lis:
        lis2[j] = 0
for k,l3 in enumerate(lis3):   
    if l3 in b_lis:
        lis3[k] = 0
if lis1 == [0,0,0]:
    print('Yes')
    sys.exit()
if lis2 == [0,0,0]:
    print('Yes')
    sys.exit()
if lis3 == [0,0,0]:
    print('Yes')
    sys.exit()
if lis1[0] == 0 and lis2[0] == 0 and lis3[0] == 0:
    print('Yes')
    sys.exit()
if lis1[1] == 0 and lis2[1] == 0 and lis3[1] == 0:
    print('Yes')
    sys.exit()
if lis1[2] == 0 and lis2[2] == 0 and lis3[2] == 0:
    print('Yes')
    sys.exit()
if lis1[0] == 0 and lis2[1] == 0 and lis3[2] == 0:
    print('Yes')
    sys.exit()
if lis1[2] == 0 and lis2[1] == 0 and lis3[0] == 0:
    print('Yes')
    sys.exit()
#print(b_lis)
#print(lis1,lis2,lis3)
print('No')

Submission status: Accepted

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
a1,a2,a3 = i2()
b1,b2,b3 = i2()
c1,c2,c3 = i2()
l = [a1,a2,a3,b1,b2,b3,c1,c2,c3]
n = i()
for i in range(n):
    k = int(input())
    if k in l:
        try:
            l[l.index(k)] = 0
        except IndexError:pass  
if (l[0] == 0 and l[1] == 0 and  l[2]== 0):
    print("Yes")
elif (l[3] == 0 and l[4] == 0 and  l[5]== 0):
    print("Yes")
elif (l[6] == 0 and l[7] == 0 and  l[8] == 0):
    print("Yes")
elif (l[0] == 0 and l[3] == 0 and  l[6]== 0):
    print("Yes")
elif (l[1] == 0 and l[4] == 0 and  l[7] == 0):
    print("Yes")
elif (l[2] == 0 and l[5] == 0 and  l[8] == 0):
    print("Yes")
elif (l[0] == 0 and l[4] == 0 and  l[8] == 0):
    print("Yes")
elif (l[2] == 0 and l[4] == 0 and l[6] == 0):
    print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
import sys
nums = []
patterns = []
for i in range(3):
    line = sys.stdin.readline().strip()
    a, b, c = map(int, line.split())
    nums.append([a,b,c])
    patterns.append([a,b,c])

# vertical
for i in range(3):
    patterns.append([nums[0][i], nums[1][i], nums[2][i]])
patterns.append([nums[0][0], nums[1][1], nums[2][2]])
patterns.append([nums[0][2], nums[1][1], nums[2][0]])

line = sys.stdin.readline().strip()
n = int(line)
tests = []
for i in range(n):
    line = sys.stdin.readline().strip()
    tests.append(int(line))

for p in patterns:
    if p[0] in tests and p[1] in tests and p[2] in tests:
        print('Yes')
        sys.exit(0)
print('No')

Submission status: Accepted

Solution code:
#a1
a1 = list(map(int, input().split()))
#a2
a2 = list(map(int, input().split()))
#a3
a3 = list(map(int, input().split()))

n = int(input())
for i in range(n):
    a=int(input())
    for j in range(len(a1)):
        if a == a1[j]:
            a1[j] = 101
        if a == a2[j]:
            a2[j] = 101
        if a == a3[j]:
            a3[j] = 101

if a1[0]+a1[1]+a1[2] == 303 \
or a2[0]+a2[1]+a2[2] == 303 \
or a3[0]+a3[1]+a3[2] == 303 \
or a1[0]+a2[0]+a3[0] == 303 \
or a1[1]+a2[1]+a3[1] == 303 \
or a1[2]+a2[2]+a3[2] == 303 \
or a1[0]+a2[1]+a3[2] == 303 \
or a1[2]+a2[1]+a3[0] == 303 :
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

p = [[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):
    if a[i][0] == a[i][1] == a[i][2] == True:
        print('Yes')
        exit()

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

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

Submission status: Accepted

Solution code:
mat=[]
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
mat=[l1,l2,l3]
N=int(input())
for r in range(N):
    n=int(input())
    for i in range(3):
        for j in range(3):
            if mat[i][j]==n:
                mat[i][j]=-1
flag=False
for i in range(3):
    if mat[i][0]==-1 and mat[i][1]==-1 and mat[i][2]==-1:
        flag=True
        break
for i in range(3):
    if mat[0][i]==-1 and mat[1][i]==-1 and mat[2][i]==-1:
        flag=True
        break
if mat[0][0]==-1 and mat[1][1]==-1 and mat[2][2]==-1:
    flag=True
if mat[0][2]==-1 and mat[1][1]==-1 and mat[2][0]==-1:
    flag=True
if flag==True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#n = int(input())
#a,b = map(int,input().split())
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))



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

for _ in range(n):
    b_L.append(int(input()))

for num in b_L:
    for i in range(0,3):
        if a_1[i] == num:
            a_1[i] = True
        if a_2[i] == num:
            a_2[i] = True
        if a_3[i] == num:
            a_3[i] = True



# 横判定
if a_1.count(True)==3 or a_2.count(True)==3 or a_3.count(True)==3:
    print("Yes")
    exit()

# 縦判定
for i in range(0,3):
    if a_1[i] == True and a_2[i] == True and a_3[i] == True:
        print("Yes")
        exit()

# 斜め判定
if a_1[0] == True and a_2[1] == True and a_3[2] == True:
    print("Yes")
    exit()
if a_1[2] == True and a_2[1] == True and a_3[0] == True:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split())
d,e,f = map(int,input().split())
g,h,i = map(int,input().split())

num = int(input())

ref = [int(input()) for i in range(num)]
jud = 0

for pp in range(num):
    if ref[pp] == a:
        a=0
    if ref[pp] == b:
        b=0
    if ref[pp] == c:
        c=0
    if ref[pp] == d:
        d=0
    if ref[pp] == e:
        e=0
    if ref[pp] == f:
        f=0
    if ref[pp] == g:
        g=0
    if ref[pp] == h:
        h=0
    if ref[pp] == i:
        i=0


if a == b == c == 0:
    jud = 1
if d == e == f == 0:
    jud = 1
if g == h == i == 0:
    jud = 1
if a == d == g == 0:
    jud = 1
if b == e == h == 0:
    jud = 1
if c == f == i == 0:
    jud = 1
if a == e == i == 0:
    jud = 1
if c == e == g == 0:
    jud = 1

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

Submission status: Accepted

Solution code:
def isBingo(listA, listB):
    count = 0
    for i in listA:
        if i in listB:
            count += 1    
        if count == 3:
            return True
    return False


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()))

tate1 = []
tate1.append(A1[0])
tate1.append(A2[0])
tate1.append(A3[0])

tate2 = []
tate2.append(A1[1])
tate2.append(A2[1])
tate2.append(A3[1])

tate3 = []
tate3.append(A1[2])
tate3.append(A2[2])
tate3.append(A3[2])

naname1 = []
naname1.append(A1[0])
naname1.append(A2[1])
naname1.append(A3[2])

naname2 = []
naname1.append(A1[2])
naname1.append(A2[1])
naname1.append(A3[0])




if isBingo(A1, b):
    print('Yes')
elif isBingo(A2, b):
    print('Yes')
elif isBingo(A3, b):
    print('Yes')
elif isBingo(tate1, b):
    print('Yes')
elif isBingo(tate2, b):
    print('Yes')
elif isBingo(tate3, b):
    print('Yes')
elif isBingo(naname1, b):
    print('Yes')
elif isBingo(naname2, b):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
class Solution:
    def solve(self, A, N: int, b) -> str:

        s = {}
        for i in range(3):
            for j in range(3):
                s[A[i][j]] = (i, j)

        isOpen = [[False] * 3 for _ in range(3)]

        for bi in b:
            if bi in s:
                isOpen[s[bi][0]][s[bi][1]] = True

        # check
        for i in range(3):
            check = True
            for j in range(3):
                if not isOpen[i][j]:
                    check = False
                    break

            if check:
                return "Yes"

        for j in range(3):
            check = True
            for i in range(3):
                if not isOpen[i][j]:
                    check = False
                    break

            if check:
                return "Yes"

        check = True
        for i in range(3):
            if not isOpen[i][i]:
                check = False
                break

        if check:
            return "Yes"

        check = True
        for i in range(3):
            if not isOpen[2-i][i]:
                check = False
                break

        if check:
            return "Yes"

        return "No"


if __name__ == '__main__':

    # standard input
    A = []
    for i in range(3):
        A.append(list(map(int, input().split())))

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

    # solve
    solution = Solution()
    print(solution.solve(A, N, b))

Submission status: Accepted

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

a=[[0]*3 for _ in range(3)] 
for bi in bl:
    for i in range(3):
        for j in range(3):
            if list1[i][j]==bi:
                a[i][j]=1
ans=0
for i in range(3): # 縦横の判別
    if a[0][i]==1 and a[1][i]==1 and a[2][i]==1:
        ans=1
    if a[i][0]==1 and a[i][1]==1 and a[i][2]==1:
        ans=1
if a[0][0]==1 and a[1][1]==1 and a[2][2]==1:
    ans=1
if a[0][2]==1 and a[1][1]==1 and a[2][0]==1:
    ans=1
if ans==0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import numpy as np

mat = list()
for _ in range(3):
    for k in [int(i) for i in input().split()]:
        mat.append(k)

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

for num in nums:
    if num in mat:
        mat[mat.index(num)] = 'bingo'

new_mat = np.array([mat[:3], mat[3:6], mat[6:]])


def solve(mat):
    for i in range(3):
        if all(num == 'bingo' for num in mat[i]):
            return 'Yes'
    for j in range(3):
        if all(num == 'bingo' for num in mat[:, j]):
            return 'Yes'
    if all([mat[0][0] == 'bingo', mat[1][1] == 'bingo', mat[2][2] == 'bingo']):
        return 'Yes'
    if all([mat[0][2] == 'bingo', mat[1][1] == 'bingo', mat[2][0] == 'bingo']):
        return 'Yes'

    return 'No'


print(solve(new_mat))

Submission status: Accepted

Solution code:
row_1 = list(map(int,input().split()))
row_2 = list(map(int,input().split()))
row_3 = list(map(int,input().split()))
row_conc = row_1 + row_2 + row_3
bingo = [0] * 9
n = int(input())
# print(row_conc,n)
for ind in range(n):
  a = int(input())
  #print(ind,a)
  for inner_ind in range(9):
    if row_conc[inner_ind] == a:
      bingo[inner_ind] = 1
if bingo[0] * bingo[3] * bingo[6] == 1:
  print("Yes")
elif bingo[1] * bingo[4] * bingo[7] == 1:
  print("Yes")
elif bingo[2] * bingo[5] * bingo[8] == 1:
  print("Yes")
elif bingo[0] * bingo[1] * bingo[2] == 1:
  print("Yes")
elif bingo[3] * bingo[4] * bingo[5] == 1:
  print("Yes")
elif bingo[6] * bingo[7] * bingo[8] == 1:
  print("Yes")
elif bingo[0] * bingo[4] * bingo[8] == 1:
  print("Yes")
elif bingo[2] * bingo[4] * bingo[6] == 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a0=list(map(int,input().split()))
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
n=int(input())
c0=[-1,-1,-1]
c1=[-1,-1,-1]
c2=[-1,-1,-1]

for i in range(n):
    b=int(input())
    for j in range(3):
        if a0[j]==b:
            c0[j]=0
    for j in range(3):
        if a1[j]==b:
            c1[j]=0
    for j in range(3):
        if a2[j]==b:
            c2[j]=0

ans=0
if c0[0]==0 and c0[1]==0 and c0[2]==0:
    ans=1
elif c1[0]==0 and c1[1]==0 and c1[2]==0:
    ans=1
elif c2[0]==0 and c2[1]==0 and c2[2]==0:
    ans=1
elif c0[0]==0 and c1[0]==0 and c2[0]==0:
    ans=1
elif c0[1]==0 and c1[1]==0 and c2[1]==0:
    ans=1
elif c0[2]==0 and c1[2]==0 and c2[2]==0:
    ans=1
elif c0[0]==0 and c1[1]==0 and c2[2]==0:
    ans=1
elif c0[2]==0 and c1[1]==0 and c2[0]==0:
    ans=1

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

Submission status: Accepted

Solution code:
array=[]

for j in range(3):
    array.append([int(i) for i in input().split(" ")])

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

flag=[0 for j in range(9)]

for i in range(3):
    for j in range(3):
        if array[i][j] in b:
            flag[i*3+j]=1

check=[
[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 check:
    sum=0
    for j in i:
        sum+=flag[j]
    if sum==3:
        print("Yes")
        exit(0)

print("No")

Submission status: Accepted

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

check=[[0,0,0],[0,0,0],[0,0,0]]

for i in range (n):
  for j in range (3):
    for k in range (3):
      if b[i]==a[j][k]:
        check[j][k]=1
        
for c in range (3):
  if check[c][0]==1 and check[c][1]==1 and check[c][2]==1:
    print('Yes')
    exit()
for e in range (3):
  if check[0][e]==1 and check[1][e]==1 and check[2][e]==1:
    print('Yes')
    exit()
if check[0][0]==1 and check[1][1]==1 and check[2][2]==1:
  print('Yes')
  exit()
if check[0][2]==1 and check[1][1]==1 and check[2][0]==1:
  print('Yes')
  exit()
  
print('No')

Submission status: Accepted

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

a = [[0,0,0] for i in range(8)]

a[0] = A[0]
a[1] = A[1]
a[2] = A[2]
a[3] = [A[0][0],A[1][0],A[2][0]]
a[4] = [A[0][1],A[1][1],A[2][1]]
a[5] = [A[0][2],A[1][2],A[2][2]]
a[6] = [A[0][0],A[1][1],A[2][2]]
a[7] = [A[0][2],A[1][1],A[2][0]]

for i in range(N) :
    for j in range(8) :
        for k in range(3) :
            if b[i] == a[j][k] :
                a[j][k] = 0
#print(a)
for i in range(8) :
    if a[i] == [0,0,0] :
        print("Yes")
        flag = True
        break

if flag == False :
    print("No")

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
N = int(input())

idx = set()

def check(mat):
    len = 1
    len *= (mat[0] + mat[1] + mat[2])
    len *= (mat[3] + mat[4] + mat[5])
    len *= (mat[6] + mat[7] + mat[8])
    len *= (mat[0] + mat[3] + mat[6])
    len *= (mat[1] + mat[4] + mat[7])
    len *= (mat[2] + mat[5] + mat[8])
    len *= (mat[0] + mat[4] + mat[8])
    len *= (mat[2] + mat[4] + mat[6])
    return len

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

if (0 == check(A)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

def if_bingo(li):
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == -1:
            return True
        if a[0][i] == a[1][i] == a[2][i] == -1:
            return True
    if a[0][0] == a[1][1] == a[2][2] == -1:
        return True
    if a[0][2] == a[1][1] == a[2][0] == -1:
        return True
    return False

for num in b:
    for i, line in enumerate(a):
        for j, sq in enumerate(line):
            if a[i][j] == num:
                a[i][j] = -1

if if_bingo(a):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
def main():
    bingo = np.zeros((3,3))
    bingo[0,:] = np.array(list(map(int, input().split())))
    bingo[1,:] = np.array(list(map(int, input().split())))
    bingo[2,:] = np.array(list(map(int, input().split())))
    N = int(input())

    for i in range(N):
        bi = int(input())
        bingo -= (bingo==bi)*bi

    ans = "No"
    
    if sum(bingo[0,:])==0 : ans = "Yes"
    if sum(bingo[1,:])==0 : ans = "Yes"
    if sum(bingo[2,:])==0 : ans = "Yes"

    if sum(bingo[:,0])==0 : ans = "Yes"
    if sum(bingo[:,1])==0 : ans = "Yes"
    if sum(bingo[:,2])==0 : ans = "Yes"
    
    if bingo[0,0]+bingo[1,1]+bingo[2,2] ==0 : ans = "Yes"
    if bingo[2,0]+bingo[1,1]+bingo[2,0] ==0 : ans = "Yes"

    print(ans)

    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
	# a = int(input())
	# n,m = map(int,input().split())
	#1行R列
	# a = list(map(int,input().split()))
	#R行1列
	# l = [str(input()) for i in range(n)]
	#R行C列
	a = [list(map(int,input().split())) for x in range(3)]
	n = int(input())
	b = [int(input()) for i in range(n)]
	# print(' '.join())

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

	for x in range(3):
		for y in range(n):
			if a[x].count(b[y]) > 0:
				bingo[x][a[x].index(b[y])] = 1
	
	bingo_check = [0,0,0]
	ans  = 0
	#斜め揃ってる時
	if bingo[0][0] == bingo[1][1] == bingo[2][2] == 1 or bingo[0][2] == bingo[1][1] == bingo[2][0] == 1:
		ans = 1
	for i in range(3):
		#よこ揃ってる時
		if bingo[i][0] == bingo[i][1] == bingo[i][2] == 1:
			ans = 1
	#たて揃ってる時
	for x in range(3):
		if bingo[0][x] == bingo[1][x] == bingo[2][x] == 1:
			ans = 1
	if ans == 1:
		print("Yes")
	else:
		print("No")


if __name__ == '__main__':
	main()

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 = [int(input()) for i in range(N)]
for i in range(N):
    for j in range(3):
        if A1[j] == b[i]:
            A1[j] = 0
        if A2[j] == b[i]:
            A2[j] = 0
        if A3[j] == b[i]:
            A3[j] = 0
if (A1[0] == A2[1] == A3[2] == 0)or(A3[0] == A2[1] == A1[2] == 0)or(A1 == [0,0,0])or(A2 == [0,0,0])or(A3 == [0,0,0])or(A1[0] == A2[0] == A3[0] == 0)or(A1[1] == A2[1] == A3[1] == 0)or(A1[2] == A2[2] == A3[2] == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = [[]]*9
a[0], a[1] ,a[2] = map(int, input().split())
a[3], a[4] ,a[5] = map(int, input().split())
a[6], a[7] ,a[8] = map(int, input().split())
N = int(input())
for n in range(N):
  b = int(input())
  for i in range(9):
    if a[i] == b:
      a[i] = 0
if a[0]+a[1]+a[2] == 0 or a[3]+a[4]+a[5] == 0 or a[6]+a[7]+a[8] == 0 or a[0]+a[3]+a[6] == 0 or a[1]+a[4]+a[7] == 0 or a[2]+a[5]+a[8] == 0 or a[0]+a[4]+a[8] == 0 or a[2]+a[4]+a[6] == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
li = []
for i in range(N):
    li.append(int(input()))
for i in range(3):
    for j in range(3):
        for k in range(N):
            if li[k] == A[i][j]:
                A[i][j] = -1
flag = 0

for i in range(3):
    if A[0][i] == A[1][i] == A[2][i] == -1:
        flag = 1
    if A[i][0] == A[i][1] == A[i][2] == -1:
        flag = 1
if A[0][0] == A[1][1] == A[2][2] == -1:
    flag = 1
if A[0][2] == A[1][1] == A[2][0] == -1:
    flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

bingo = [False] * 9

def num_check(num):
    for i in range(9):
        if A[i] == num:
            bingo[i] = True


for _ in range(N):
    num = int(input())
    num_check(num)

bingo_flag = False
# row check
if any([bingo[i] and bingo[i+1] and bingo[i+2] for i in range(0, 9, 3)]):
    bingo_flag = True

# col check
if any([bingo[i] and bingo[i+3] and bingo[i+6] for i in range(3)]):
    bingo_flag = True

# cross check
if (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bingo[4] and bingo[6]):
    bingo_flag = True

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

Submission status: Accepted

Solution code:
import sys

a = [[0] * 3 for _ in range(3)]
a[0] = list(map(int, sys.stdin.readline().strip().split()))
a[1] = list(map(int, sys.stdin.readline().strip().split()))
a[2] = list(map(int, sys.stdin.readline().strip().split()))
n = int(sys.stdin.readline().strip())
b = [0] * n
for i in range(n):
    b = int(sys.stdin.readline().strip())

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


def is_bingo():
    # horizontal
    for r in range(3):
        if a[r][0] + a[r][1] + a[r][2] == 0:
            return True
    # vertical
    for c in range(3):
        if a[0][c] + a[1][c] + a[2][c] == 0:
            return True

    if a[0][0] + a[1][1] + a[2][2] == 0:
        return True
    if a[2][0] + a[1][1] + a[0][2] == 0:
        return True

    return False


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

Submission status: Accepted

Solution code:
import numpy as np

A1=np.array(input().split(" "),dtype=np.int32)
A2=np.array(input().split(" "),dtype=np.int32)
A3=np.array(input().split(" "),dtype=np.int32)

A=[A1,A2,A3]

N=int(input())

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

T=np.zeros((3,3),dtype=np.int32)

for n in range(N):
    value=B[n]
    for i in range(3):
        for j in range(3):
            if(value==A[i][j]):
                T[i][j]=1

# horizontal
flag=False
for i in range(3):
    cnt=0
    for j in range(3):
        if(T[i][j]==0):
            break
        else:
            cnt+=1
    if(cnt==3):
        flag=True

# vertical
for i in range(3):
    cnt=0
    for j in range(3):
        if(T[j][i]==0):
            break
        else:
            cnt+=1
    if(cnt==3):
        flag=True

if(T[0][0]==1 and T[1][1]==1 and T[2][2]==1):
    flag=True
elif(T[0][2]==1 and T[1][1]==1 and T[2][0]==1):
    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 = set(int(input()) for _ in range(n))

ans = 'No'

if len(set(A[0])&B)==3:
  ans = 'Yes'
elif len(set(A[1])&B)==3:
  ans = 'Yes'
elif len(set(A[2])&B)==3:
  ans = 'Yes'
elif len(set([A[0][0], A[1][0], A[2][0]])&B)==3:
  ans = 'Yes'
elif len(set([A[0][1], A[1][1], A[2][1]])&B)==3:
  ans = 'Yes'
elif len(set([A[0][2], A[1][2], A[2][2]])&B)==3:
  ans = 'Yes'
elif len(set([A[0][0], A[1][1], A[2][2]])&B)==3:
  ans = 'Yes'
elif len(set([A[0][2], A[1][1], A[2][0]])&B)==3:
  ans = 'Yes'
  
print(ans)

Submission status: Accepted

Solution code:
A = []
R = [0]*9
def flag(A):
    if (A[0]*A[1]*A[2]==1)or(A[3]*A[4]*A[5]==1)or(A[6]*A[7]*A[8]==1):
        return 'Yes'
    if (A[0]*A[3]*A[6]==1)or(A[1]*A[4]*A[7]==1)or(A[2]*A[5]*A[8]==1):
        return 'Yes'
    if (A[0]*A[4]*A[8]==1)or(A[2]*A[4]*A[6]==1):
        return 'Yes'
    return 'No'

for i in range(3):
    A += list(map(int, input().split()))
n = int(input())
for i in range(n):
    b = int(input())
    if b in A:
        R[A.index(b)] = 1
print(flag(R))

Submission status: Accepted

Solution code:
A=[]
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
#A00,A01,A02 = map(int, input().split())
#A10,A11,A12 = map(int, input().split())
#A20,A21,A22 = map(int, input().split())
N=int(input())
b=[int(input()) for i in range(N)]

#print(A)
#print(b)

for k in range(3):
    if A[0][k] in b and A[1][k] in b and A[2][k] in b:
        print('Yes')
        exit()
    elif A[k][0] in b and A[k][1] in b and A[k][2] in b:
        print('Yes')
        exit()
if A[0][0] in b and A[1][1] in b and A[2][2] in b:
    print('Yes')
    exit()
elif A[0][2] in b and A[1][1] in b and A[0][2] in b:
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
a=[0]*9
a[0],a[1],a[2]=map(int, input().split())
a[3],a[4],a[5]=map(int, input().split()) 
a[6],a[7],a[8]=map(int, input().split()) 
N=int(input())
B=[]
for i in range(N):
  B.append(int(input()))
S=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
ans='No'
for lis in S:
  n=0
  if ans=="Yes":
    break
  for i in range(3):
    if a[lis[i]] in B:
      n+=1
    if n==3:
      ans="Yes"

print(ans)

Submission status: Accepted

Solution code:
A = []
A_t = []
for i in range(3):
    A.append(list(map(int, input().split())))
    A_t.append([None] * 3)
for i in range(3):
    for j in range(3):
        A_t[j][i] = A[i][j]
n = int(input())
B = [None] * n
for i in range(n):
    B[i] = int(input())
ans = A + A_t + [[A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]]
for i in range(len(ans)):
    if (all([
        ans[i][0] in B,
        ans[i][1] in B,
        ans[i][2] in B
    ])):
        print('Yes')
        exit()
else:
    print('No')

Submission status: Accepted

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

#print("Yes") print("No")

lll=[]
for i in range(3):
    for j in range(3):
        if l[i][j] in ll:
            lll.append([i,j])

a=0
if [0,0] in lll and [0,1] in lll and [0,2] in lll:
    a+=1
if [1,0] in lll and [1,1] in lll and [1,2] in lll:
    a+=1
if [2,0] in lll and [2,1] in lll and [2,2] in lll:
    a+=1
if [0,0] in lll and [1,0] in lll and [2,0] in lll:
    a+=1
if [0,1] in lll and [1,1] in lll and [2,1] in lll:
    a+=1
if [0,2] in lll and [1,2] in lll and [2,2] in lll:
    a+=1
if [0,0] in lll and [1,1] in lll and [2,2] in lll:
    a+=1
if [0,2] in lll and [1,1] in lll and [0,2] in lll:
    a+=1

if a==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
mybingo = []

for n in range(3):
    mybingo += [list(map(int, input().split()))]
#print(mybingo)

N = int(input())
for n in range(N):
    mynum = int(input())
    for m in mybingo:
        if mynum in m:
            m[m.index(mynum)] = 0
#print(mybingo)

#横check
for m in mybingo:
    if len(set(m)) == 1 and m[0] == 0:
        print('Yes')
        sys.exit()
#縦
for w in range(3):
    mycnt = 0
    for h in range(3):
        if mybingo[h][w] == 0:
            mycnt += 1
        else:
              break
    if mycnt == 3:
        print('Yes')
        sys.exit()
#斜め
h = [0,1,2]
w = [0,1,2]
mypos = 0 
mycnt = 0
while mypos < 3:
    if mybingo[h[mypos]][w[mypos]] == 0:
        mycnt += 1
    mypos += 1
if mycnt == 3:
    print('Yes')
    sys.exit()

h = [0,1,2]
w = [2,1,0]
mypos = 0 
mycnt = 0
while mypos < 3:
    if mybingo[h[mypos]][w[mypos]] == 0:
        mycnt += 1
    mypos += 1
if mycnt == 3:
    print('Yes')
    sys.exit()
    
print("No")

Submission status: Accepted

Solution code:
Aa = list(map(int, input().split()))
Ab = list(map(int, input().split()))
Ac = list(map(int, input().split()))
At = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
N = int(input())

for i in range(N):
    tmp = int(input())
    if tmp in Aa:
        At[0][Aa.index(tmp)] = 1
    if tmp in Ab:
        At[1][Ab.index(tmp)] = 1
    if tmp in Ac:
        At[2][Ac.index(tmp)] = 1

if all(At[0]) or all(At[1]) or all(At[2]):
    print('Yes')
    exit()

if At[0][0] and At[1][0] and At[2][0] \
   or At[0][1] and At[1][1] and At[2][1] \
   or At[0][2] and At[1][2] and At[2][2]:
    print('Yes')
    exit()

if At[0][0] and At[1][1] and At[2][2] \
   or At[0][2] and At[1][1] and At[2][0]:
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
a1 = [int(i) for i in input().split()]
a2 = [int(j) for j in input().split()]
a3 = [int(k) for k in input().split()]
b1 = set([a1[0], a2[0], a3[0]])
b2 = set([a1[1], a2[1], a3[1]])
b3 = set([a1[2], a2[2], a3[2]])
c1 = set([a1[0], a2[1], a3[2]])
c2 = set([a1[2], a2[1], a3[0]])
a1 = set(a1)
a2 = set(a2)
a3 = set(a3)
n = int(input())
for l in range(n) :
    num = int(input())
    if num in a1 :
        a1.remove(num)
    if num in a2 :
        a2.remove(num)
    if num in a3 :
        a3.remove(num)
    if num in b1 :
        b1.remove(num)
    if num in b2 :
        b2.remove(num)
    if num in b3 :
        b3.remove(num)
    if num in c1 :
        c1.remove(num)
    if num in c2 :
        c2.remove(num)
if len(a1) == 0 or len(a2) == 0 or len(a3) == 0 or len(b1) == 0 or len(b2) == 0 or len(b3) == 0 or len(c1) == 0 or len(c2) == 0 :
    print("Yes")
else :
    print("No")

Submission status: Accepted

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

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

for i in range(n):
    for j in range(3):
        if b[i] in bingo[j]:
            result[j][bingo[j].index(b[i])] = True

# 横
for i in result:
    if all(i):
        print('Yes')
        exit()
# 縦
for i in range(3):
    if all([result[0][i], result[1][i], result[2][i]]):
        print('Yes')
        exit()
# 斜め
if all([result[0][0], result[1][1], result[2][2]]) or all([result[0][2], result[1][1], result[2][0]]):
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
a = [[int(i) for i in input().split()] for j in range(3)]
ans = [[0 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 b==a[i][j]:
                ans[i][j] += 1
text ="No"

for i in range(3):
    if sum(ans[i])==3:
        text ="Yes"
    if sum([j[i] for j in ans])==3:
        text ="Yes"
    if sum([ans[j][j] for j in range(3)])==3:
        text ="Yes"
    if sum([ans[j][2-j] for j in range(3)])==3:
        text ="Yes"

print(text)

#print(sum([j[i] for j in ans]))