Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

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

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

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

Sample Input 2

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

Sample Output 2

No

We will mark nothing.

Sample Input 3

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

Sample Output 3

Yes

We will mark all the squares.



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


Sample output:
Yes

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import numpy as np
b_card = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
nums = [int(input()) for _ in range(N)]

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

for num in nums:
    for index, card_num in enumerate(b_card):
        if num in card_num:
            card_st[index][card_num.index(num)] = 1

if True in np.all(card_st, axis=0):
    print('Yes')
elif True in np.all(card_st, axis=1):
    print('Yes')
elif np.all(np.diag(card_st) == 1):
    print('Yes')
elif np.all(np.diag(np.fliplr(card_st)) == 1):
    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 _ in range( n ):
    b.append( int( input() ) )

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

for i in range( 3 ):
    for j in range( 3 ):
        if a[ i ][ j ] in b:
            bingo[ i ][ j ] = True

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

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

if bingo[ 0 ][ 0 ] and bingo[ 1 ][ 1 ] and bingo[ 2 ][ 2 ]:
    print( "Yes" )
    exit()

if bingo[ 0 ][ 2 ] and bingo[ 1 ][ 1 ] and bingo[ 2 ][ 0 ]:
    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()))
a = a1+a2+a3

n = int(input())

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

if a[0]==a[1]==a[2] or a[3]==a[4]==a[5] or a[6]==a[7]==a[8] or a[0]==a[3]==a[6]\
or a[1]==a[4]==a[7] or a[2]==a[5]==a[8] or a[0]==a[4]==a[8] or a[2]==a[4]==a[6]:
    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 = [int(input()) for _ in range(n)]

if a1[0] in b and a1[1] in b and a1[2] in b:
  print('Yes')
elif a2[0] in b and a2[1] in b and a2[2] in b:
  print('Yes')
elif a3[0] in b and a3[1] in b and a3[2] in b:
  print('Yes')
elif a1[0] in b and a2[0] in b and a3[0] in b:
  print('Yes')
elif a1[1] in b and a2[1] in b and a3[1] in b:
  print('Yes')
elif a1[2] in b and a2[2] in b and a3[2] in b:
  print('Yes')
elif a1[0] in b and a2[1] in b and a3[2] in b:
  print('Yes')
elif a1[2] in b and a2[1] in b and a3[0] in b:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import numpy as np
a = np.array([input().split() for _ in range(3)])
n = int(input())
b = [int(input()) for _ in range(n)]

def bingo(sheet, called):
    sheet = np.where(sheet == called, 0, sheet)
    return sheet

for i in range(n):
    a = bingo(a, str(b[i]))

#print(a)
check = 0
for j in range(3):
    if a[j][0] == a[j][1] and a[j][2] == a[j][0] == '0':
        check += 1
    if a[0][j] == a[1][j] and a[2][j] == a[0][j] == '0':
        check += 1
if a[0][0] == a[1][1] and a[2][2] == a[0][0] == '0':
    check += 1
if a[0][2] == a[1][1] and a[2][0] == a[0][2] == '0':
    check += 1

print('No' if check == 0 else 'Yes')

Submission status: Accepted

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

C = []
  
C.append(A[0])
C.append(A[1])
C.append(A[2])
C.append([A[0][0], A[1][0], A[2][0]])
C.append([A[0][1], A[1][1], A[2][1]])
C.append([A[0][2], A[1][2], A[2][2]])
C.append([A[0][0], A[1][1], A[2][2]])
C.append([A[0][2], A[1][1], A[2][0]])

flag = False

for c in C:
  if len(set(c)&set(B)) == 3:
    flag = True
    break
    
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = list([int(input()) for _ in range(n)])
ans = "No"

# ana check
for bi in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == bi:
                a[i][j] = "hole"

# tate bingo
for j in range(3):
    if a[0][j] == "hole":
        if a[1][j] == "hole" and a[2][j] == "hole":
            ans = "Yes"

# yoko bingo
for i in range(3):
    if a[i][0] == "hole":
        if a[i][1] == "hole" and a[i][2] == "hole":
            ans = "Yes"

# naname bingo
if a[0][0] == "hole" and a[1][1] == "hole" and a[2][2] == "hole":
    ans = "Yes"
if a[0][2] == "hole" and a[1][1] == "hole" and a[2][0] == "hole":
    ans = "Yes"

print(ans)

Submission status: Accepted

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

N = int(input())

for n in range(N):
    b = int(input())
    flag = False
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1
                flag = True
                break
        if flag:
            break

C = [0]*8
for i in range(3):
    for j in range(3):
        if i == j:
            C[6] += B[i][j]
        if i+j==2:
            C[7] += B[i][j]
        C[i] += B[i][j]
        C[j+3] += B[i][j]

for i in range(8):
    if C[i]==3:
        print('Yes')
        break
    if i == 7:
        print('No')

Submission status: Accepted

Solution code:
A = list(input().split() for i in range(3))
n = int(input())
r1 = set(A[0])
r2 = set(A[1])
r3 = set(A[2])
c1 = {A[0][0], A[1][0], A[2][0]}
c2 = {A[0][1], A[1][1], A[2][1]}
c3 = {A[0][2], A[1][2], A[2][2]}
d1 = {A[0][0], A[1][1], A[2][2]}
d2 = {A[0][2], A[1][1], A[2][0]}
b = set(input() for i in range(n))
if r1.issubset(b) or r2.issubset(b) or r3.issubset(b) or c1.issubset(b) or c2.issubset(b) or c3.issubset(b) or d1.issubset(b) or d2.issubset(b):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a1,a2,a3,_,*b = [i.split() for i in open(0)]
bingo = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [2, 5, 8], [0, 3, 6], [1, 4, 7], [0, 4, 8], [2, 4, 6]]
s = ["" if i in sum(b,[]) else i for i in a1 + a2 + a3]
for i,j,k in bingo:
    if {s[i],s[j],s[k]} ==  {''}:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

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

def bingo(A):
	for i in range(3):
		tmp = 0 
		for j in range(3):
			tmp += A[i][j]
		if tmp == 3:
			return True

	for i in range(3):
		tmp = 0 
		for j in range(3):
			tmp += A[j][i]
		if tmp == 3:
			return True

	if A[0][2] + A[1][1] + A[2][0] == 3 or A[0][0] + A[1][1] + A[2][2] == 3:
		return True

	else:
		return False


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

Submission status: Accepted

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

result = [[0]*3 for _ in range(3)]

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

for h in result:
    if 0 not in h:
        print("Yes")
        exit()

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

if result[0][0] == result[1][1] == result[2][2] == 1:
    print("Yes")
    exit()

if result[0][2] == result[1][1] == result [2][0] == 1:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

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

for _ in range(n):
    b = int(input())
    for i, row in enumerate(a):
        for j, col in enumerate(row):
            if a[i][j]==b:
                bingo[i][j]=True

for i in range(3):
    if all([bingo[i][j] for j in range(3)]):
        print('Yes')
        exit()
    if all([bingo[j][i] for j in range(3)]):
        print('Yes')
        exit()

if all([bingo[i][i] for i in range(3)]):
    print('Yes')
    exit()
if all([bingo[i][2-i] for i in range(3)]):
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def isBingoYoko(ans):
    for bool_i_list in ans:
        for bj in bool_i_list:
            if bj==False:
                break
            else:
                pass
        else:
            print("Yes")
            exit(0)

def isBingoNaname(ans):
    if (ans[0][0] and ans[1][1] and ans[2][2]) or ((ans[0][2] and ans[1][1] and ans[2][0])):
        print("Yes")
        exit(0)
    else:
        pass

def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    ans = [[False for _ in range(3)] for _ in range(3)]
    for b in B:
        for i in range(len(A)):
            if b in A[i]:
                j = A[i].index(b)
                ans[i][j] = True

    isBingoYoko(ans)
    isBingoYoko(list(numpy.array(ans).T))
    isBingoNaname(ans)
    print("No")

main()

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def isBingoYoko(ans):
    for bool_i_list in ans:
        for bj in bool_i_list:
            # print(bool_i_list)
            if bj==False:
                break
            else:
                pass
        else:
            print("Yes")
            exit(0)

def isBingoNaname(ans):
    if (ans[0][0] and ans[1][1] and ans[2][2]) or ((ans[0][2] and ans[1][1] and ans[2][0])):
        print("Yes")
        exit(0)
    else:
        pass

def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    ans = [[False for _ in range(3)] for _ in range(3)]
    for b in B:
        for i in range(len(A)):
            if b in A[i]:
                j = A[i].index(b)
                ans[i][j] = True

    isBingoYoko(ans)
    isBingoYoko(list(numpy.array(ans).T))
    isBingoNaname(ans)
    print("No")

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
al = []
ans = 'No'
for i in range(3):
    al.append(list(map(int, input().split())))
n = int(input())
bl = [int(input()) for i in range(n)]
for i in bl:
    for a in al:
        if i in a:
            a[a.index(i)]=0           
t1 = al[0][0]+al[1][1]+al[2][2]
t2 = al[0][2]+al[1][1]+al[2][0]
if t1 ==0 or t2==0:
    ans = 'Yes'
else:
    for a in al:
        if sum(a)==0:
            ans = 'Yes'
            break
        else:
            for va in zip(*al):
                if sum(va)==0:
                    ans = 'Yes'
                    break
print(ans)

Submission status: Accepted

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

ans=[[0,0,0],[0,0,0],[0,0,0]]

flag=True

for j in range(N):
    for row in range(3):
        for col in range(3):
            if bingolist[j]==List[row][col]:
                ans[row][col]=1
for i in range(3):
    if ans[i][0]*ans[i][1]*ans[i][2]==1:
        print('Yes')
        flag=False
        break
    elif ans[0][i]*ans[1][i]*ans[2][i]:
        print('Yes')
        flag=False
        break
    elif ans[0][0]*ans[1][1]*ans[2][2]==1:
        print('Yes')
        flag=False
        break
    elif ans[0][2]*ans[1][1]*ans[2][0]==1:
        print('Yes')
        flag=False
        break
if flag:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[46]:


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


# In[47]:


cnddt = []
for i in range(len(A)):
    cnddt.append(A[i])
for i in range(len(A)):
    cnddt.append([x[i] for x in A])
cnddt.append([A[0][0],A[1][1],A[2][2]])
cnddt.append([A[0][2],A[1][1],A[2][0]])
# print(cnddt)
for i,cnddt_i in enumerate(cnddt):
    mylist = [x for x in cnddt_i if x not in b]
#     print(mylist)
    if len(mylist) == 0:
        print("Yes")
        break
else:
    print("No")


# In[ ]:

Submission status: Accepted

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

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

    if all(a[i][i] == 1 for i in range(3)) or (a[0][2] == a[1][1] == a[2][0] == 1):
        print("Yes")
        return
    else:
        for i in range(3):
            if all(a[i][j] == 1 for j in range(3)) or all(a[j][i] == 1 for j in range(3)):
                print("Yes")
                return

    print("No")

B()

Submission status: Accepted

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

xx = sum(x, [])

tate1 = xx[0:9:3]
tate2 = xx[1:9:3]
tate3 = xx[2:9:3]
yoko1 = xx[0:3]
yoko2 = xx[3:6]
yoko3 = xx[6:9]
nana1 = xx[0:9:4]
nana2 = xx[2:7:2]

if rows >= 3 and (set(tate1) <= set(y) or set(tate2) <= set(y) or set(tate3) <= set(y) or set(yoko1) <= set(y) or set(yoko2) <= set(y) or set(yoko3) <= set(y) or set(nana1) <= set(y) or set(nana2) <= set(y)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                ls[i][j] = 1

for i in range(3):
    if sum(ls[i]) == 3:
        print('Yes')
        exit()
    if ls[0][i]*ls[1][i]*ls[2][i] == 1:
        print('Yes')
        exit()

if ls[0][0]*ls[1][1]*ls[2][2] == 1:
    print('Yes')
    exit()

if ls[0][2]*ls[1][1]*ls[2][0] == 1:
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
import numpy as np

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

A = np.array(A)
flag = False
for a in A:
    if a.sum() == 0:
        flag = True
for a in A.T:
    if a.sum() == 0:
        flag = True

if np.diag(A).sum()==0:
    flag = True
if np.diag(np.fliplr(A)).sum()==0:
    flag = True

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

Submission status: Accepted

Solution code:
#graph implementation
import math
ls=[]
for i in range(3):
    ls.append(list(map(int,input().split())))
ans=[[0,0,0],[0,0,0],[0,0,0]]
n=int(input())
for i in range(n):
    a=int(input())
    for j in range(3):
        for k in range(3):
            if a==ls[j][k]:
                ans[j][k]=1
res=[]
for i in range(3):
    total=0
    for j in range(3):
        total+=ans[i][j]
    res.append(total)
var=0
while var<3:
    total=0
    for i in range(3):
        total+=ans[i][var]
    var+=1
    res.append(total)
res.append(ans[0][0]+ans[1][1]+ans[2][2])
res.append(ans[0][2]+ans[1][1]+ans[2][0])
res.sort()
#print(res)
#print(ans)
if res[len(res)-1]==3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

#a = [[84, 97, 66], [79, 89, 11], [61, 59, 7]]
#b = [89, 7, 87, 79, 24, 84, 30]
c = set(b)

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

ck = 0
for i in range(3):
  if a[i] == [0,0,0]:
    ck = 1
    break
  if ( a[0][i],a[1][i],a[2][i] ) == (0,0,0):
    ck = 1
    break

if ( a[0][0],a[1][1],a[2][2] ) == (0,0,0):
  ck = 1
if ( a[2][0],a[1][1],a[0][2] ) == (0,0,0):
  ck = 1

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

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
	x = int(input())
	for h in range(3):
		for w in range(3):
			if a[h][w] == x:
				a[h][w] = 0
for i in range(3):
	if a[i][0] == a[i][1] == a[i][2] == 0:
		print("Yes")
		exit()
	elif a[0][i] == a[1][i] == a[2][i] == 0:
		print("Yes")
		exit()
if a[0][0] == a[1][1] == a[2][2] == 0:
	print("Yes")
elif a[2][0] == a[1][1] == a[0][2] == 0:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

A = [LI() for i in range(3)]
N = I()
b = [I() for i in range(N)]

B = [[0]*3 for i in range(3)]  #当たりなら1,外れなら0

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

for i in range(3):
    if (len(set(B[i])) == 1 and B[i][0] == 1) or (len(set([B[j][i] for j in range(3)])) == 1 and B[0][i] == 1):
        print('Yes')
        exit()
if B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    print('Yes')
    exit()
if B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
    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()))
n = int(input())
d=[]
for i in range(n):
    d.append(int(input()))


def bingo(i):
    if i in d:
        return True
    else:
        return False

if bingo(a[0]) and bingo(a[1]) and bingo(a[2]):
    print('Yes')
elif bingo(b[0]) and bingo(b[1]) and bingo(b[2]):
    print('Yes')
elif bingo(c[0]) and bingo(c[1]) and bingo(c[2]):
    print('Yes')
elif bingo(a[1]) and bingo(b[1]) and bingo(c[1]):
    print('Yes')
elif bingo(a[0]) and bingo(b[0]) and bingo(c[0]):
    print('Yes')
elif bingo(a[2]) and bingo(b[2]) and bingo(c[2]):
    print('Yes')
elif bingo(a[2]) and bingo(b[1]) and bingo(c[0]):
    print('Yes')
elif bingo(a[0]) and bingo(b[1]) and bingo(c[2]):
    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()))

A = A1 + A2 + A3
N = int(input())

index = []
for i in range(N):
    inp = int(input())
    if inp in A:
        index.append(A.index(inp))

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

Submission status: Accepted

Solution code:
l=[0]*3
for i in range(3):
    a=list(map(int,input().split()))
    l[i]=a
n=int(input())
bingo=[[1]*3 for _ in range(3)]
b=[]
for i in range(n):
    B=int(input())
    b.append(B)
for i in range(3):
    for j in range(3):
        if l[i][j] in b:
            bingo[i][j]=0
x=0
cnt1=0
cnt2=0
cnt3=0
nana1=0
nana2=0
for i in range(3):
    if sum(bingo[i])==0:
        print("Yes")
        x=1
        break
    cnt1+=bingo[i][0]
    cnt2+=bingo[i][1]
    cnt3+=bingo[i][2]
    nana1+=bingo[i][i]
    nana2+=bingo[i][2-i]
if x==0:
    if cnt1==0 or cnt2==0 or cnt3==0 or nana1==0 or nana2==0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

n = int(input())

b = []

for j in range(n):
    b.append(int(input()))
    
for k in range(9):
    for l in b:
        if bingo[k] == l:
            bingo[k] = 0
            
flag = 0

if (bingo[0] == 0 and bingo[1] == 0 and bingo[2] == 0) or (bingo[3] == 0 and bingo[4] == 0 and bingo[5] == 0) or (bingo[6] == 0 and bingo[7] == 0 and bingo[8] == 0):
    flag = 1

if (bingo[0] == 0 and bingo[3] == 0 and bingo[6] == 0) or (bingo[1] == 0 and bingo[4] == 0 and bingo[7] == 0) or (bingo[2] == 0 and bingo[5] == 0 and bingo[8] == 0):
    flag = 1

if (bingo[0] == 0 and bingo[4] == 0 and bingo[8] == 0) or (bingo[2] == 0 and bingo[4] == 0 and bingo[6] == 0):
    flag = 1
    
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc157/tasks/abc157_b

a=[]
for _ in range(3):
    num_a=list(map(int,input().split()))
    for i in range(3):
        a.append(num_a[i])
n=int(input())
res=[-1 for i in range(9)]
for i in range(n):
    b=int(input())
    if b in a:
        num_index=a.index(b)
        res[num_index]=1

for i in range(3):
    if (res[i]==res[i+3])&(res[i+3]==res[i+6])&(res[i]==1):
        print("Yes")
        exit()
for i in range(3):
    if (res[3*i]==res[3*i+1])&(res[3*i+1]==res[3*i+2])&(res[3*i]==1):
        print("Yes")
        exit()
if ((res[0]==res[4])&(res[4]==res[8])&(res[0]==1))|((res[2]==res[4])&(res[4]==res[6])&(res[2]==1)):
    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()))
n = int(input())
s = list(map(int, [input() for i in range(n)]))
l = [
  [0, 0, 0]
  , [0, 0, 0]
  , [0, 0, 0]
]
for i in range(0, 3):
  for j in range(0, n):
    if a1[i] == s[j]:
      l[0][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a2[i] == s[j]:
      l[1][i] = i+1
for i in range(0, 3):
  for j in range(0, n):
    if a3[i] == s[j]:
      l[2][i] = i+1
n = []
for i in l:
  for j in i:
    if j != 0:
      n.append(j)
count = 0
for i in range(0, 3):
  if l[i][0] and l[i][1] and l[i][2]:
    count += 1
if (l[0][0] and l[1][1] and l[2][2]) or (l[2][0] and l[1][1] and l[0][2]):
  count += 1
else:
  for i in range(1, 4):
    if n.count(i) == 3:
      count += 1
print('Yes' if count >= 1 else 'No')

Submission status: Accepted

Solution code:
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]
f=[0]*9
flag=False
for i in range(N):
  for j in range(3):
    for k in range(3):
      if(b[i]==A[j][k]):
        f[3*j+k]=1
if((f[0]==1 and f[1]==1 and f[2]==1)or(f[3]==1 and f[4]==1 and f[5]==1)or(f[6]==1 and f[7]==1 and f[8]==1)):
  flag=True
elif((f[0]==1 and f[3]==1 and f[6]==1)or(f[1]==1 and f[4]==1 and f[7]==1)or(f[2]==1 and f[5]==1 and f[8]==1)):
  flag=True
elif((f[0]==1 and f[4]==1 and f[8]==1)or(f[2]==1 and f[4]==1 and f[6]==1)):
  flag=True
if(flag==True):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
lst = [[v for v in map(int, input().split())] for _ in range(3)]
cnt = int(input())
for _ in range(cnt):
    v = int(input())
    for x in range(3):
        for y in range(3):
            if lst[x][y] == v:
                lst[x][y] = '*'
def bingo():
    for _ in range(3):
        if lst[_][0] == lst[_][1] == lst[_][2]:
            return print('Yes')
        if lst[0][_] == lst[1][_] == lst[2][_]:
            return print('Yes')
    if lst[0][0] == lst[1][1] == lst[2][2]:
        return print('Yes')
    if lst[0][2] == lst[1][1] == lst[2][0]:
        return print('Yes')
    else:
        return print('No')

bingo()

Submission status: Accepted

Solution code:
def resolve():
    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)]
 
    A = A1 + A2 + A3
    checkA = [0]*9
    for i in range(N):
        if b[i] in A:
            checkA[A.index(b[i])] = 1
    if checkA[0] + checkA[1] + checkA[2] == 3:
        print('Yes')
    elif checkA[3] + checkA[4] + checkA[5] == 3:
        print('Yes')
    elif checkA[6] + checkA[7] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[3] + checkA[6] == 3:
        print('Yes')
    elif checkA[1] + checkA[4] + checkA[7] == 3:
        print('Yes')
    elif checkA[2] + checkA[5] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[4] + checkA[8] == 3:
        print('Yes')
    elif checkA[2] + checkA[4] + checkA[6] == 3:
        print('Yes')
    else:
        print('No')
resolve()

Submission status: Accepted

Solution code:
def resolve():
    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)]

    A = A1 + A2 + A3
    checkA = [0]*9
    for i in range(N):
        if b[i] in A:
            checkA[A.index(b[i])] = 1
    if checkA[0] + A[1] + A[2] == 3:
        print('Yes')
    elif checkA[3] + checkA[4] + checkA[5] == 3:
        print('Yes')
    elif checkA[6] + checkA[7] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[3] + checkA[6] == 3:
        print('Yes')
    elif checkA[1] + checkA[4] + checkA[7] == 3:
        print('Yes')
    elif checkA[2] + checkA[5] + checkA[8] == 3:
        print('Yes')
    elif checkA[0] + checkA[4] + checkA[8] == 3:
        print('Yes')
    elif checkA[2] + checkA[4] + checkA[6] == 3:
        print('Yes')
    else:
        print('No')
resolve()

Submission status: Accepted

Solution code:
a = []
appear = [[False, False, False], [False, False, False], [False, False, False]]

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

n = int(input())
b = [0] * n
for j in range(n):
    b[j] = int(input())

for s in range(3):
    for t in range(3):
        for j in range(n):
            if a[s][t] == b[j]:
                appear[s][t] = True
ans = 'No'
if appear[0][0] and appear[1][1] and appear[2][2]:
    ans = 'Yes'
for s in range(3):
    if appear[s][0] and appear[s][1] and appear[s][2]:
        ans = 'Yes'
    if appear[0][s] and appear[1][s] and appear[2][s]:
        ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
    ans = 'Yes'
print(ans)