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: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for i in range(3)]
l=sum(l,[])
n=int(input())
li=set([input() for ini in range(n)])
d=[0 for i in range(9)]
for g in range(9):
  if l[g] in li:d[g]=1
for a,s,x in [(0,1,2),(3,4,5),(6,7,8),(0,4,8),(2,4,6),(0,3,6),(1,4,7),(2,5,8)]:
  if d[a]==d[x]==d[s]==1:
    print("Yes");exit()
print("No")

Submission status: Wrong Answer

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


bing=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(0,3):
    if r1[i] in a:
        bing[0][i]=1
    if r2[i] in a:
        bing[1][i]=1
    if r3[i] in a:
        bing[2][i]=1


ans=0

if sum(bing[0])==3 or sum(bing[1])==3 or sum(bing[2])==3:
    ans += 1

if bing[0][0]+bing[1][0]+bing[2][0]==3 or bing[0][1]+bing[1][1]+bing[2][1]==3 or bing[0][2]+bing[1][2]+bing[2][2]==3:
    ans += 1

if bing[0][0]+bing[1][1]+bing[2][2]==3 or bing[2][2]+bing[1][1]+bing[0][0]==3:
    ans +=1

if ans >=1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for i in range(3)]
l=sum(l,[])
n=int(input())
li=set([input() for ini in range(n)])
d=[0 for i in range(9)]
for g in range(9):
  if l[g] in li:d[g]=1
if set([1]) in [set(d[h::3])for h in range(3)]+[set(d[h:h+3])for h in {0,3,6}]+[set([d[0],d[4],d[8]]),set([d[2],d[4],d[6]])]:
  print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for i in range(3)]
l=sum(l,[])
n=int(input())
li=set([input() for ini in range(n)])
d=[0 for i in range(9)]
for g in range(9):
  if l[g] in li:d[g]=1
if set([1]) in [set(d[h::3])for h in range(3)]+[set(d[h:h+3])for h in range(3)]+[set([d[0],d[4],d[8]]),set([d[2],d[4],d[6]])]:
  print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
A=[]
for i in range(3):
    l=[int(a) for a in input().split()]
    A.extend(l)
for i in range(int(input())):
    b=int(input())
    if b in A:
        A[A.index(b)]=0
na=np.array(A)
ra=na.reshape(3,3)
flg=False
fa=np.count_nonzero(ra==0,axis=0)
fb=np.count_nonzero(ra==0,axis=1)
if np.any(fa==3) or np.any(fb==3):
    flg=True
flg2=flg3=True    
for i in range(3):
    if ra[i][i]!=0:
        flg2=False
    if ra[i][-1-i]!=0:
        flg3=False
if flg or flg2 or flg3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
A=[]
for i in range(3):
    l=[int(a) for a in input().split()]
    A.extend(l)
for i in range(int(input())):
    b=int(input())
    if b in A:
        A[A.index(b)]=0
na=np.array(A)
ra=na.reshape(3,3)
flg=False
fa=np.count_nonzero(ra==0,axis=0)
fb=np.count_nonzero(ra==0,axis=1)
if np.any(fa==3) or np.any(fb==3):
    flg=True
flg2=flg3=True    
for i in range(3):
    if ra[i][i]!=0:
        flg2=False
    if ra[i][-1+i]!=0:
        flg3=False
if flg or flg2 or flg3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = [[0 for i in range(3)] for j in range(3)]

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

N = int(input())
judge = [0 for i in range(9)]
ans = 'No'

for i in range(N):
    b = int(input())
    
    for row in range(3):
        if (b in A[row]):
            index_r = A[row].index(b)
            index = 3 * row + index_r
            judge[index] += 1

for i in range(3):
    summ1 = sum(judge[i::3])
    summ2 = sum(judge[3 * i : 3 * i + 3])
    
    if (summ1 == 3 or summ2 == 3):
        ans = 'Yes'

summ3 = sum(judge[0::4])
summ4 = sum(judge[2:6:2])

if (summ3 == 3 or summ4 == 3):
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
A = [[0 for i in range(3)] for j in range(3)]

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

N = int(input())
judge = [0 for i in range(9)]
ans = 'No'

for i in range(N):
    b = int(input())
    
    for row in range(3):
        if (b in A[row]):
            index_r = A[row].index(b)
            index = 3 * row + index_r
            judge[index] += 1

for i in range(3):
    summ1 = sum(judge[i::3])
    summ2 = sum(judge[i: i + 3])
    
    if (summ1 == 3 or summ2 == 3):
        ans = 'Yes'

summ3 = sum(judge[0::4])
summ4 = sum(judge[2:6:2])

if (summ3 == 3 or summ4 == 3):
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
r = [0] * 3
c = [0] * 3
d = [0] * 2
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                r[i] += 1
                c[j] += 1
                if i == j:
                    d[0] += 1
                    if i == 1:
                        d[1] += 1
                elif abs(i - j) == 2:
                    d[1] += 1

if max(max(r), max(c), max(d)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = [None for i in range(101)]  # 1 ~ 100まで
bingo = [[0] * 4 for i in range(4)]  # 3 * 3
row = [None, 0, 0, 0]
col = [None, 0, 0, 0]
cross = [None, 0, None, 0]
is_bingo = False


def solve(n):
    global is_bingo
    if is_bingo:
        return
    # 保存場所の取得
    if A[n] is None:
        return
    idx = int(A[n])
    i = int(idx / 10)
    j = int(idx % 10)
    row[i] += 1
    col[j] += 1
    if i == j and i + j == 4:
        cross[1] += 1
        cross[3] += 1
    elif i == j and i + j != 4:
        cross[1] += 1
    elif i != j and i + j == 4:
        cross[3] += 1

    if row[i] == 3 or col[i] == 3 or cross[1] == 3 or cross[3] == 3:
        is_bingo = True


# main
if __name__ == '__main__':
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '11'
    A[idx[1]] = '12'
    A[idx[2]] = '13'
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '21'
    A[idx[1]] = '22'
    A[idx[2]] = '23'
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '31'
    A[idx[1]] = '32'
    A[idx[2]] = '33'
    n = int(input())
    for i in range(0, n):
        solve(int(input()))
    if is_bingo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
A = [None for i in range(101)]  # 1 ~ 100まで
bingo = [[0] * 4 for i in range(4)]  # 3 * 3
row = [None, 0, 0, 0]
col = [None, 0, 0, 0]
cross = [None, 0, None, 0]
is_bingo = False


def solve(n):
    global is_bingo
    if is_bingo:
        return
    # 保存場所の取得
    if A[n] is None:
        return
    idx = int(A[n])
    i = int(idx / 10)
    j = int(idx % 10)
    bingo[i][j] = 1
    row[i] += 1
    col[j] += 1
    if i == j:
        cross[1] += 1
    elif i + j == 4:
        cross[3] += 1
    if row[i] == 3 or col[i] == 3 or cross[1] == 3 or cross[3] == 3:
        is_bingo = True


# main
if __name__ == '__main__':
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '11'
    A[idx[1]] = '12'
    A[idx[2]] = '13'
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '21'
    A[idx[1]] = '22'
    A[idx[2]] = '23'
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '31'
    A[idx[1]] = '32'
    A[idx[2]] = '33'
    n = int(input())
    for i in range(0, n):
        solve(int(input()))
    if is_bingo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 22:38:51 2020

@author: Kanaru Sato
"""

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

N = int(input())

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

flag = [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]

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

column = 0
raw = 0
naname = 0

for i in range(0,3):
    column += flag[i][0]*flag[i][1]*flag[i][2]
    raw += flag[0][i]*flag[1][i]*flag[2][i]
naname = flag[0][0]*flag[1][1]*flag[2][2]+flag[0][2]*flag[1][1]*flag[2][0]

print(flag)

if column>=1 or raw>=1 or naname>=1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
line1 = list(map(int,input().split()) )
line2 = list(map(int,input().split()))
line3 = list(map(int,input().split()))

N = int(input())
num = []
for _ in range(N):
    num.append(int(input()))
card = line1 + line2 + line3
result = []
for i in card:
    if i in num:
        result.append(1)
    else:
        result.append(0)
count = 0
for i in range(0,7,3):
    if result[i] == 1 and result[i + 1] == 1 and result[i + 2] == 1:
        count = 1
        print("Yes")
if count == 0:
    for i in range(3):
        if result[i] == 1 and result[i+3] == 1 and result[i+6] == 1:
            count = 1
            print("Yes")
if count == 0:
    if result[0] == result[4] == result[8] == 1:
        count = 1
        print("Yes")
if count == 0:
    if result[2] == result[4] == result[6] == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
li_a = list(input().split())
li_a += list(input().split())
li_a += list(input().split())
n = int(input())

for i in range(n):
    b = input()
    if b in li_a:
        idx = li_a.index(b)
        li_a[idx] = "o"
if any(
    [all(a == "o" for a in li_a[:3]),
    all(a == "o" for a in li_a[3:6]),
    all(a == "o" for a in li_a[6:]),
    all(a == "o" for a in li_a[::3]),
    all(a == "o" for a in li_a[1::3]),
    all(a == "o" for a in li_a[2::3]),
    all(a == "o" for a in li_a[::4]),
    all(a == "o" for a in li_a[2:9:2])]
    ):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#157b
a_array = []
a_array.append(list(map(int, input().split())))
a_array.append(list(map(int, input().split())))
a_array.append(list(map(int, input().split())))

N = int(input())
b_set = set()

for i in range(N):
    b_set.add(int(input()))
    
bingos = [[a_array[0][0],a_array[0][1],a_array[0][1]],
         [a_array[1][0],a_array[1][1],a_array[1][1]],
         [a_array[2][0],a_array[2][1],a_array[2][1]],
         [a_array[0][0],a_array[1][0],a_array[2][0]],
         [a_array[0][1],a_array[1][1],a_array[2][1]],
         [a_array[0][2],a_array[1][2],a_array[2][2]],
         [a_array[0][0],a_array[1][1],a_array[2][2]],
         [a_array[0][2],a_array[1][1],a_array[2][0]]]

for bingo in bingos:
    if bingo[0] in b_set and bingo[1] in b_set and bingo[2] in b_set:
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#157b
a=[[int(i) for i in input().split()] for _ in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
               a[j][k]=0
print("a", a)
ans='No'
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        ans='Yes'
    elif a[0][i]==a[1][i]==a[2][i]:
        ans='Yes'
    elif a[0][0]==a[1][1]==a[2][2]:
        ans='Yes'
    elif a[0][2]==a[1][1]==a[2][0]:
        ans='Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

def run():
  A = [list(map(int, input().split())) for n in range(3)]
  A = np.array(A)
  N = int(input())
  for n in range(N):
    b = int(input())
    for i in range(3):
      for j in range(3):
        a = A[i][j]
        if a == b:
          A[i][j] = 0
  print(A)
  ans = 1
  left = 0
  right = 0
  for i in range(3):
    ans = min(ans, np.sum(A, axis=0)[i])
    ans = min(ans, np.sum(A, axis=1)[i])
    left += A[i][i]
    right += A[i][2-i]
  ans = min(ans, left, right)
  if ans == 0:
    print('Yes')
  else:
    print('No')
    

if __name__ == '__main__':
  run()

Submission status: Wrong Answer

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

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

marked = [False]*9
for i in b:
    for ind, num in enumerate(a):
        if i==num:
            marked[ind] = True
            break

bingos = [
    (0,1), (3,1), (6,1), (0,3), (1,3), (2,3), (0,4), (2,2)
]

for start, step in bingos:
    for i in range(start, 9, step):
        if not marked[i]:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = (int(x) for x in input().split())
A21, A22, A23 = (int(x) for x in input().split())
A31, A32, A33 = (int(x) for x in input().split())
N = int(input())
B = []

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

for b in B:
    if b == A11:
        A11 = True
    if b == A12:
        A12 = True
    if b == A13:
        A13 = True
    if b == A21:
        A11 = True
    if b == A22:
        A12 = True
    if b == A23:
        A13 = True
    if b == A31:
        A11 = True
    if b == A32:
        A12 = True
    if b == A33:
        A13 = True

if A11 == True and A12 == True and A13 == True:
    print("yes")
elif A11 == True and A21 == True and A31 == True:
    print("yes")
elif A11 == True and A22 == True and A33 == True:
    print("yes")
elif A11 == True and A12 == True and A13 == True:
    print("yes")
elif A21 == True and A22 == True and A23 == True:
    print("yes")
elif A31 == True and A32 == True and A33 == True:
    print("yes")
elif A12 == True and A22 == True and A32 == True:
    print("yes")
elif A13 == True and A23 == True and A33 == True:
    print("yes")
elif A13 == True and A22 == True and A31 == True:
    print("yes")
else:
    print("no")

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = (int(x) for x in input().split())
A21, A22, A23 = (int(x) for x in input().split())
A31, A32, A33 = (int(x) for x in input().split())
N = int(input())
B = []

for i in range(N):
    B.append(int(input()))
    
for b in B:
    if b == A11:
        A11 = True
    if b == A12:
        A12 = True
    if b == A13:
        A13 = True
    if b == A21:
        A11 = True
    if b == A22:
        A12 = True
    if b == A23:
        A13 = True
    if b == A31:
        A11 = True
    if b == A32:
        A12 = True
    if b == A33:
        A13 = True

if A11 and A12 and A13:
    print("yes")
elif A11 and A21 and A31:
    print("yes")
elif A11 and A22 and A33:
    print("yes")
elif A11 and A12 and A13:
    print("yes")
elif A21 and A22 and A23:
    print("yes")
elif A31 and A32 and A33:
    print("yes")
elif A12 and A22 and A32:
    print("yes")
elif A13 and A23 and A33:
    print("yes")
elif A13 and A22 and A31:
    print("yes")
else:
    print("no")

Submission status: Wrong Answer

Solution code:
#157b
a=[[int(i) for i in input().split()] for _ in range(3)]

n=int(input())
b=[[int(i) for i in input().split()] for _ in range(n)]
for i in range(3):
	for j in range(3):
		for e in b:
			if a[i][j]==e:
				a[i][j]=0
ans='No'
for i in range(3):
	if a[i][0]==a[i][1]==[i][2]:
		ans='Yes'
	elif a[0][i]==a[1][i]==a[2][i]:
		ans='Yes'
	elif a[0][0]==a[1][1]==a[2][2]:
		ans='Yes'
	elif a[0][2]==a[1][1]==a[2][0]:
		ans='Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
#157b
a=[[int(i) for i in input().split()] for _ in range(3)]

n=int(input())
b=[int(i) for i in input().split()]
for i in range(3):
	for j in range(3):
		for e in b:
			if a[i][j]==e:
				a[i][j]=0
ans='No'
for i in range(3):
	if a[i][0]==a[i][1]==[i][2]:
		ans='Yes'
	elif a[0][i]==a[1][i]==a[2][i]:
		ans='Yes'
	elif a[0][0]==a[1][1]==a[2][2]:
		ans='Yes'
	elif a[0][2]==a[1][1]==a[2][0]:
		ans='Yes'
print(ans)

Submission status: Wrong Answer

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

A_t = [list(i) for i in zip(*A)]


def main(A, b):
    for i in range(3):
        cnt = 0
        for j in range(3):
            if A[i][j] in b:
                cnt += 1
        if cnt == 3:
            return "Yes"

    for i in range(3):
        cnt = 0
        for j in range(3):
            if A_t[i][j] in b:
                cnt += 1
        if cnt == 3:
            return "Yes"

    # for i in range(3):
    #     for j in range(3):
    # if not A[i][j] in b:
    #     break
    # if j == 2:
    #     return "Yes"

    if (A[0][0] and A[1][1] and A[2][2]) in b:
        return "Yes"

    if (A[0][2] and A[1][1] and A[2][0]) in b:
        return "Yes"

    return "No"


ans = main(A, b)
print(ans)

Submission status: Wrong Answer

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


def main(A, b):
    for i in range(3):
        for j in range(3):
            if not A[i][j] in b:
                break
            if j == 2:
                return "Yes"

    if (A[0][0] and A[1][1] and A[2][2]) in b:
        return "Yes"

    if (A[0][2] and A[1][1] and A[2][0]) in b:
        return "Yes"

    return "No"


ans = main(A, b)
print(ans)

Submission status: Wrong Answer

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


def main(A, b):
    for i in range(3):
        for j in range(3):
            if not A[i][j] in b:
                break
        return "Yes"

    if (A[0][0] and A[1][1] and A[2][2]) in b:
        return "Yes"

    if (A[0][2] and A[1][1] and A[2][0]) in b:
        return "Yes"

    return "No"


ans = main(A, b)
print(ans)

Submission status: Wrong Answer

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


def main(A, b):
    for i in range(3):
        for j in range(3):
            if not A[i][j] in b:
                break
            return "Yes"

    if (A[0][0] and A[1][1] and A[2][2]) in b:
        return "Yes"

    if (A[0][2] and A[1][1] and A[2][0]) in b:
        return "Yes"

    return "No"


ans = main(A, b)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
def main():
    a_list = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    b_list = [int(input()) for _ in range(n)]
    for b in b_list:
        tmp = np.argwhere(a_list == b).tolist()
        if tmp:
            a_list[tmp[0][0], tmp[0][1]] = 0
    print(a_list)
    for i in range(3):
        # 横
        if all([a == 0 for a in a_list[i]]):
            print("Yes")
            return
    # 縦
    for i in range(3):
        if all([a_list[j][i] == 0 for j in range(3)]):
            print("Yes")
            return
    # ななめ
    if a_list[0][0] == a_list[1][1] == a_list[2][2] == 0:
        print("Yes")
        return
    if a_list[0][2] == a_list[1][1] == a_list[2][0] == 0:
        print("Yes")
        return
    print("No")
main()

Submission status: Wrong Answer

Solution code:
import numpy as np
def main():
    a_list = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    b_list = [int(input()) for _ in range(n)]
    for b in b_list:
        tmp = np.argwhere(a_list == b).tolist()
        if tmp:
            a_list[tmp[0][0], tmp[0][1]] = 0

    for i in range(3):
        # 横
        if all([a == 0 for a in a_list[i]]):
            print("Yes")
            return
    # 縦
    for i in range(3):
        if all([a_list[j][i] == 0 for j in range(3)]):
            print("Yse")
            return
    # ななめ
    if a_list[0][0] == a_list[1][1] == a_list[2][2] == 0:
        print("Yes")
        return
    if a_list[0][2] == a_list[1][1] == a_list[2][0] == 0:
        print("Yes")
        return
    print("No")
main()

Submission status: Wrong Answer

Solution code:
import numpy as np
def main():
    a_list = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    b_list = [int(input()) for _ in range(n)]
    for b in b_list:
        tmp = np.argwhere(a_list == b).tolist()
        if tmp:
            a_list[tmp[0][0], tmp[0][1]] = 0

    for i in range(3):
        # 横
        if all([a == 0 for a in a_list[i]]):
            print("Yes")
            return
    # 縦
    for i in range(3):
        if all([a_list[j][i] == 0 for j in range(3)]):
            print("Yse")
            return
    # ななめ
    if a_list[0][0] == a_list[1][1] == a_list[2][2]:
        print("Yes")
        return
    if a_list[0][2] == a_list[1][1] == a_list[2][0]:
        print("Yes")
        return
    print("No")
main()

Submission status: Wrong Answer

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 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] == 0 and A[i][1] == 0 and A[i][2] == 0:
        ans = "Yes"
    elif A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        ans = "Yes"
    elif A[0][0] and A[1][1] and A[2][2] == 0:
        ans = "Yes"
    elif A[0][2] and A[1][1] and A[2][0] == 0:
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
#ABC-157-B
#ビンゴゲーム
#coding utf-8
import math

a = [list(map(int,input().split())) for _ in range(3)]#2次元配列の入力
n = int(input())
b = [int(input()) for _ in range(n)]#n回入力(行変え)
flag = [[False] * 3 for _ in range(3)]#判定のためのbool変数

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            flag[i][j] = True#aにbが含まれていたらflag[][]をTrueに
#ここから判別していく
#行
for row in flag:
    if all(row): #組み込み関数all()
        """
        組み込み関数all()は、()の中のすべての要素がTrueならTrueを返す
        """
        print('Yes')
        exit()
#列
for i in range(3):
    tmp = 0
    for j in range(3):
        if flag[i][j]:
            tmp += 1
    
    if tmp == 3:
        print('Yes')
        exit()
#斜め
if flag[0][0] and flag[1][1] and flag[2][2]:
    print('Yes')
    exit()
if flag[0][2] and flag[1][1] and flag[2][0]:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ans  = [[False]*3 for _ in range(3)]
result = 'No'
for i in range(3):
  for j in range(3):
    for k in b:
      if a[i][j] == k:
        ans[i][j] = True 
for i in range(3):
  cnt = 0
  for j in range(3):
    if ans[j][i]:
      cnt += 1
  if cnt == 3:
    result = 'Yes'
    break
if ans[0][0] and ans[1][1] and ans[2][2]:
  result = "Yes"
if ans[0][2] and ans[1][1] and ans[2][0]:
  result = "Yes"
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
L =[]
for i in range(3):
    a,b,c = map(int,input().split())
    L.append([a,b,c])
n = int(input())
li = []
for i in range(n):
    li.append(int(input()))
for i in range(3):
    flag = False
    for j in range(3):
        if L[i][j] in li:
            flag = True
        else:
            flag = False
            break
if flag:
    print("Yes")
    exit()
for i in range(3):
    flag = False
    for j in range(3):
        if L[j][i] in li:
            flag = True
        else:
            flag = False
            break
if flag:
    print("Yes")
    exit()
for i in range(3):
    flag = False
    if L[i][2-i] in li:
        flag = True
    else:
        flag = False
        break
if flag:
    print("Yes")
    exit()
for i in range(3):
    flag = False
    if L[i][i] in li:
        flag = True
    else:
        flag = False
        break
if flag:
    print("Yes")
    exit()
else:
    print("No")

Submission status: Wrong Answer

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

li = [[False]*3 for _ in range(3)]
ans = 'No'

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


for i in range(3):
    if False not in li[i]:
        ans = 'Yes'

for i in range(3):
    if all((li[j][i] == True for j in range(3))):
        ans = 'Yes'

for i in range(3):
    if all((li[i][i] == True for i in range(3))):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from bisect import bisect_left
import sys,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a = [inpl() for i in range(3)]
c = [[False] * 3 for i in range(3)]
n = inp()
b = [inp() for i in range(n)]
for x in b:
    for i in range(3):
        for j in range(3):
            if x == a[i][j]:
                c[i][j] = True
res = False
for i in range(3):
    if c[i].count(True) == 3:
        res = True
for i in range(3):
    for j in range(3):
        if not c[j][i]:
            break
    res = True
for i in range(3):
    if not c[i][i]:
        break
    res = True
if c[0][2] == c[1][1] == c[2][0] == True:
    res = True
print('Yes' if res else 'No')

Submission status: Wrong Answer

Solution code:

ls_a = []
for i in range(3):
    ls_a.extend(list(map(int,input().split())))
n = int(input())
ls_b = [int(input()) for i in range(n)]

for i in range(9):
    if ls_a[i] in ls_b:
        ls_a[i] = 0

print(ls_a,ls_b)
for i in range(3):
    if ls_a[i] == 0 and ls_a[i+3] == 0 and ls_a[i+6] == 0:
        print("Yes")
        exit()
    if ls_a[i*3] == 0 and ls_a[i*3+1] == 0 and ls_a[i*3+2] == 0:
        print("Yes")
        exit()
if ls_a[0] == 0 and ls_a[4] == 0 and ls_a[8] == 0:
    print("Yes")
    exit()
if ls_a[2] == 0 and ls_a[4] == 0 and ls_a[6] == 0:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:

ls_a = []
for i in range(3):
    ls_a.extend(list(map(int,input().split())))
n = int(input())
ls_b = [int(input()) for i in range(n)]

for i in range(9):
    if ls_a[i] in ls_b:
        ls_a[i] = 0
for i in range(3):
    if ls_a[i] == 0 and ls_a[i+3] == 0 and ls_a[i+6] == 0:
        print("Yes")
        exit()
    if ls_a[i*3] == 0 and ls_a[i*3+1] == 0 and ls_a[i*3+2] == 0:
        print("Yes")
        exit()
if ls_a[0] == 0 and ls_a[3] == 0 and ls_a[8] == 0:
    print("Yes")
    exit()
if ls_a[2] == 0 and ls_a[4] == 0 and ls_a[6] == 0:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:

ls_a = []
for i in range(3):
    ls_a.extend(list(map(int,input().split())))
n = int(input())
ls_b = [int(input()) for i in range(n)]

for i in range(9):
    if ls_a[i] in ls_b:
        ls_a[i] = 0
for i in range(3):
    if ls_a[i] == 0 and ls_a[i+3] == 0 and ls_a[i+6] == 0:
        print("Yes")
        exit()
if ls_a[0] == 0 and ls_a[3] == 0 and ls_a[8] == 0:
    print("Yes")
    exit()
if ls_a[2] == 0 and ls_a[4] == 0 and ls_a[6] == 0:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

def x ():
    for i in range(3):
        if (appear[i][0] and appear[i][1] and appear[i][2] ):
            return "Yes"
    for i in range(3):
        if (appear[0][i] and appear[1][i] and appear[2][i]):
            return "Yes"
    if (appear[0][0] and appear[1][1] and appear[2][2]):
        return "Yes"
    if (appear[0][2] and appear[1][1] and appear[2][0]):
        return "Yes"
    return "No"
print(x())

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
x = [0] * 3
y = [0] * 3
z = [0] * 3
for i in range(3):
    x[i], y[i], z[i] = map(int, input().split())
            
n = int(input())
b = [int(input()) for _ in range(n)]
    
ans = [x, y, z]

for i in range(3):
  ans.append([x[i], y[i], z[i]])
  
ans.append([x[0],y[1],z[2]])
ans.append([x[2],y[1],z[0]])

cnt = 0
for i in range(len(ans)):
  for j in list(set(x+y+z) & set(b)):
    if j in ans[i]:
      cnt += 1
      
if cnt >= 3:
  print('Yes')
else:
  print('No')