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:
bingo = [[],[],[]]
 
for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
  ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

b1 = [0,0,0]
b2 = [0,0,0]
b3 = [0,0,0]

for i in range(n):
    b = int(input())
    for j in range(3):
        if a1[j] == b:
            b1[j] = 1
        if a2[j] == b:
            b2[j] = 1
        if a3[j] == b:
            b3[j] = 1

if b1[0] == 1 and b1[1] == 1 and b1[2] == 1:
    print("yes")
elif b2[0] == 1 and b2[1] == 1 and b2[2] == 1:
    print("yes")
elif b3[0] == 1 and b3[1] == 1 and b3[2] == 1:
    print("yes")
elif b1[0] == 1 and b2[0] == 1 and b3[0] == 1:
    print("yes")
elif b1[1] == 1 and b2[1] == 1 and b3[1] == 1:
    print("yes")
elif b1[2] == 1 and b2[2] == 1 and b3[2] == 1:
    print("yes")
elif b1[0] == 1 and b2[1] == 1 and b3[2] == 1:
    print("yes")
elif b1[2] == 1 and b2[1] == 1 and b3[0] == 1:
    print("yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = []
for i in range(N):
	b.append(int(input()))
	
yoko = A
tate = [[], [], []]
for row in A:
	for i in range(3):
		tate[i].append(row[i])
naname = [[A[0][0], A[1][1], A[2][2]]]

all = yoko + tate + naname

chk = 0
for kumi in all:
	for k in kumi:
		if k in b:
			chk += 1
		else:
			continue
	if chk == 3:
		print("Yes")
		break
	else:
		chk = 0
		
if chk == 0:
	print("No")

Submission status: Wrong Answer

Solution code:
from itertools import product
card=[input().split() for _ in range(3)]
checked_row=[[False for _ in range(3)] for _ in range(3)]
checked_col=[[False for _ in range(3)] for _ in range(3)]

n=int(input())
for _ in range(n):
  b=input()
  for i,j in product(range(3),repeat=2):
    if card[i][j]==b:
      checked_row[i][j]=True
      checked_col[j][i]=True
if(
  any(all(r) for r in checked_row)
  or any(all(c) for c in checked_col)
  or all(checked_row[i][i]) for _ in range(3)
  or all(checked_row[i][2-i]) for _ in range(3)
  ):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

N = int(input())
number = []

for j in range(N):
    number.append(int(input()))

result = []
for n in range(N):
    for t in range(3):
        for y in range(3):
            if(bingo[t][y] == number[n]):
                result.append([t,y])

bingo_a = 'No'
for r in range(len(result)):
    for t in range(3):
        flag = True
        for y in range(3):
            if(result[r][0] != t or result[r][1] != y):
                flag = False
        if(flag == True):
            bingo_a = 'Yes'

for r in range(len(result)):
    for y in range(3):
        flag = True
        for t in range(3):
            if(result[r][0] != t or result[r][1] != y):
                flag = False
        if(flag == True):   
            bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 0):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 2):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 2):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 0):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

print(bingo_a)
print(result)

Submission status: Wrong Answer

Solution code:
import sys
N = 3

# 2次元配列
A = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    A.append(array)

A_t = [list(x) for x in zip(*A)]
A_n = [[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]
N = int(input())
B=[]
cnt = [0]*3
for i in range(N):
    B.append(int(input()))
    
cnt[0] =0
num = 0
for j in A:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 2 in cnt:
    print("yes")
    sys.exit(0)
cnt = [0,0,0]
num = 0
for j in A_t:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 2 in cnt:
    print("yes")
    sys.exit()
cnt = [0,0,0]
num = 0
for j in A_n:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 2 in cnt:
    print("yes")
else:
    print("no")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def main():
    bingo_map = [[0] * 3 for _ in range(3)]
    number_list = []
    for _ in range(3):
        A, B, C = map(int, input().split())
        number_list.append(A)
        number_list.append(B)
        number_list.append(C)
    N = int(input())
    for _ in range(N):
        b = int(input())
        if b in number_list:
            pos = number_list.index(b)
            bingo_map[pos//3][pos%3] = 1
        else:
            continue
    nagomi = bingo_map[0][0] + bingo_map[1][1] + bingo_map[2][2]
    kugoi  = bingo_map[0][2] + bingo_map[1][1] + bingo_map[2][0]
    nahaku = bingo_map[0][0] + bingo_map[0][1] + bingo_map[0][2]
    shigoro = bingo_map[1][0] + bingo_map[1][1] + bingo_map[1][2]
    hifumi = bingo_map[2][0] + bingo_map[2][1] + bingo_map[2][2]
    nashii = bingo_map[0][0] + bingo_map[1][0] + bingo_map[2][0]
    yagoni = bingo_map[0][1] + bingo_map[1][1] + bingo_map[2][1]
    kuromi = bingo_map[0][2] + bingo_map[2][1] + bingo_map[2][2]
    if nagomi == 3 or kugoi == 3 or nahaku == 3 or shigoro == 3 or hifumi == 3 or nashii == 3 or yagoni == 3 or kuromi == 3:
        print("Yes")
    else:
        print("No")
 
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

li1 = list(map(int,input().split()))
li1.extend(list(map(int,input().split())))
li1.extend(list(map(int,input().split())))
n = int(input())
for i in range(n):
  p = int(input())
  li1 = [0 if j == p else j for j in li1]
print(li1)
if ( li1[0] + li1[1] + li1[2] ) == 0:
  print('Yes')
elif ( li1[3] + li1[4] + li1[5] ) == 0:
  print('Yes')
elif ( li1[6] + li1[7] + li1[8] ) == 0:
  print('Yes')
elif ( li1[0] + li1[3] + li1[6] ) == 0:
  print('Yes')
elif ( li1[1] + li1[4] + li1[7] ) == 0:
  print('Yes')
elif ( li1[2] + li1[5] + li1[8] ) == 0:
  print('Yes')
elif ( li1[0] + li1[4] + li1[8] ) == 0:
  print('Yes')
elif ( li1[2] + li1[4] + li1[6] ) == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[0]*3]*3
    for i in range(3): #aを順番に見ていく
        for j in range(3):
            if a[i][j] in b:
                card[i][j] =1
    for i in range(3): # card
        if i == 0:
            if card[i][i] == card[i][i+1] == card[i][i+2]==1:#縦の探索
                print("Yes")
                break
            elif card[i][i] == card[i+1][i] == card[i+2][i]==1:#横の探索
                print("Yes")
                break
            elif card[i][i] == card[i+1][i+1] == card[i+2][i+2]==1:#0の時の斜め            
                print("Yes")
                break
        elif i == 1:
            if card[i-1][i] == card[i][i] == card[i+1][i]==1:
                print("Yes")
                break
        elif i == 2:
            if card[i-2][i] == card[i-1][i-1] == card[i][i-2] == 1:#2のときの斜
                print("Yes") 
                break   
    else:print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

b = []

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


for i in range(len(b)):
  for a_i in range(len(A[0])):
    for a_j in range(len(A[1])):
      if A[a_i][a_j] == b[i]:
        A[a_i][a_j] = 0

ok = 0

# print(all([i == 0 for i in A[0]]))

for j in range(3):
  if all([i == 0 for i in A[j]]):
    ok += 1

for i in range(3):
  if (A[i][0] == A[i][1] == A[i][2]):
    ok += 1

for i in range(3):
  if A[i][i] != 0:
    break
  if i == 2:
    ok += 1

if A[0][2] == A[1][1] == A[2][0]:
  ok += 1

if ok > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
# B
import sys
a_list = []
a = []
f = True
c = [False for i in range(9)]
for i in range(3):
    a_list = list(map(int, input().split()))
    for num in a_list:
        a.append(num)
n = int(input())
for i in range(n):
    num = int(input())
    if num in a:
        index = a.index(num)
        c[index] = True
        if not f:
            if (c[0] and c[3] and c[6]) or (c[1] and c[4] and c[7]) or (c[2] and c[5] and c[8]) or (c[0] and c[1] and c[2]) or (c[3] and c[4] and c[5]) or (c[6] and c[7] and c[8]) or (c[0] and c[4] and c[8]) or (c[2] and c[4] and c[6]):
                print('Yes')
                f = False
if f:
    print('No')

Submission status: Wrong Answer

Solution code:
def common_member(a, b): 
    a_set = set(a) 
    b_set = set(b) 
    if (a_set & b_set): 
        return a_set & b_set
    else: 
        return "a"

L = list(map(int,input().split()))
L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))
LL = L + L1 + L2
N = int(input())
M = []
for i in range(N):
    ML = input()
    M.append(int(ML))

res = len(common_member(M,LL))
if(res == 1):
    print("No")
elif (res >= (N/2)):
    print("Yes")

Submission status: Wrong Answer

Solution code:
list1=[0]*3
list2=[0]*3
list3=[0]*3
list4=[0]*3
c=0
for i in range(3):
    list1[i], list2[i],  list3[i]= map(int, input().split())
n=int(input())
for j in range(n):
    b=int(input())
    if b in list1:
        list1[list1.index(b)]=0
    if b in list2:
        list2[list2.index(b)]=0
    if b in list3:
        list3[list3.index(b)]=0
for i in range(3):
    list4[i]=list1[i]+list2[i]+list3[i]
d=list1[0]+list2[1]+list3[2]
e=list1[2]+list2[1]+list3[1]
if sum(list1)==0 or sum(list2)==0 or sum(list3)==0 or d==0 or e==0 or(0 in list4):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = [input().split() for l in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans = 'No'
for i in range(3):
        for j in range(3):
                for k in range(N):
                        a[i][j] = int(a[i][j])
                        if a[i][j] == b[k]:
                        

                                a[i][j] = 0
for i in range(3):
        if a[i][0] + a[i][1] + a[i][2] == 0:
                ans = 'Yes'
for i in range(3):
        if a[0][i] + a[0][i] + a[0][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: Wrong Answer

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

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

for b in B:
    if b in A1:
        A1[A1.index(b)] = 0
    if b in A2:
        A2[A2.index(b)] = 0
    if b in A3:
        A3[A3.index(b)] = 0

if sum(A1) * sum (A2) * sum(A3) == 0:
    print("Yes")
elif (A1[0]+A2[0]+A3[0]) * (A1[1]+A2[1]+A3[1]) * (A1[2]+A2[2]+A3[2]) * (A1[0]+A2[1]+A3[2]) * (A1[2]+A2[1]+A2[0]) == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
A_1 = [int(i) for i in input().split()]
A_2 = [int(i) for i in input().split()]
A_3 = [int(i) for i in input().split()]
A = np.array([A_1, A_2, A_3])
N = int(input())
b = [int(input()) for i in range(N)]
for i in b:
   A = np.where(A==i,0,A) 

if A[0][0]==A[1][1] and A[1][1] == A[2][2] and A[0][0]==0:
    print('Yes')
elif A[2][0]==A[1][1] and A[1][1] == A[0][2] and A[2][0]==0:
    print('Yes')
elif A[0,:].all()==0 or A[:,0].all()==0:
    print('Yes')
elif A[1,:].all()==0 or A[:,1].all()==0:
    print('Yes')
elif A[2,:].all()==0 or A[:,2].all()==0:
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
A=[]
A1=[]
A2=[]
A3=[]
for i in range(3):
  x, y, z = map(str, input().split())
  A.append(x)
  A.append(y)
  A.append(z)
N=int(input())
b = []
for _ in range(N):
  b.append(str(input()))
for i in range(N):
  A=[s.replace(b[i],'0') for s in A]
flag=False
if A[0]=='0':
  if A[1]=='0':
    if A[2]=='0':
      flag=True
  if A[3]=='0':
    if A[6]=='0':
      flag=True
  if A[4]=='0':
    if A[8]=='0':
      flag=True
if A[1]=='0':
  if A[4]=='0':
    if A[7]=='0':
      flag=True
if A[2]=='0':
  if A[4]=='0':
    if A[6]=='0':
      flag =True
  if A[5]=='0':
    if A[8]=='0':
      flag=True
if A[3]=='0':
  if A[4]=='0':
    if A[5]=='0':
      flag =True
if A[6]=='0':
  if A[7]=='0':
    if A[8]=='0':
      flag =True
if flag==True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a,b,c =map(int,input().split())
d,e,f =map(int,input().split())
g,h,i =map(int,input().split())
N=input()
N= int(N)
z = [ input() for i in range(N)]
if z == a and d and z== b and e and h or z== c and f and i or z == a and b and c or z== d and e and f or z == g and h and i or z== a and e and i or z ==c and e and g:
  print('Yes')
else :
  print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(int(1e6))

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

N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())

c = [[0]*3]*3
n = 0
for bn in b:
    for m in range(3*3):
        i = m % 3
        j = m // 3
        if (A[i][j] == bn):
            c[i][j] = 1
            break

ans = 'No'
for i in range(3):
    if sum(c[i]) == 3:
        ans = 'Yes'
        break
    if sum([c[0][i], c[1][i], c[2][i]]) == 3:
        ans = 'Yes'
        break
else:
    if sum([c[0][0], c[1][1], c[2][2]]) == 3:
        ans = 'Yes'
    elif sum([c[2][0], c[1][1], c[0][2]]) == 3:
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
def common_member(a, b): 
    a_set = set(a) 
    b_set = set(b) 
    if (a_set & b_set): 
        return a_set & b_set
    else: 
        return "a"

L = list(map(int,input().split()))
L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))
LL = L + L1 + L2
N = int(input())
M = []
for i in range(N):
    ML = input()
    M.append(int(ML))

res = len(common_member(M,LL))
print(res)
print(common_member(M,LL))
if(res == 1):
    print("No")
elif (res >= (N/2)):
    print("Yes")

Submission status: Wrong Answer

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



for k in range(n):
    b = input()
    for i in range(3):
      for j in range(3):
        if(b in a[i][j]):
          a[i][j] = 'maru'
          #print('OK')
      

frag = False




for k in range(3):
    i = 0
    #縦
    if((a[i][k] == 'maru') and (a[i+1][k] == 'maru')and(a[i+2][k] == 'maru')):
        frag = True


for k in range(3):
    j = 0
    #横
    if((a[k][j] == 'maru') and (a[k][j+1] == 'maru')and(a[k][j+2] == 'maru')):
        frag = True


#斜め
if((a[0][0] == 'maru')and(a[1][1] == 'maru')and(a[2][2]=='maru')):
    frag = True
if((a[2][0] == 'maru')and(a[1][1] == 'maru')and(a[0][2]=='maru')):
    frag = True
        

if(frag == True):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A_1 = input().split()
A_2 = input().split()
A_3 = input().split()

N = int(input())

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

ans = "No"


if A_1[0] in B_list:
    if A_2[0] in B_list and A_3[0] in B_list:
        ans = "Yes"
    elif A_1[1] in B_list and A_1[2] in B_list:
        ans = "Yes"
    elif A_2[1] in B_list and A_3[2] in B_list:
        ans = "Yes"
elif A_1[1] in B_list and A_2[1] in B_list and A_3[1] in B_list:
    ans = "Yes"
elif A_1[2] in B_list and A_2[1] in B_list and A_3[0] in B_list:
    ans = "Yes"
elif A_2[0] in B_list and A_2[1] in B_list and A_2[2] in B_list:
    ans = "Yes"
elif A_3[0] in B_list and A_3[1] in B_list and A_3[2] in B_list:
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

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

for k in range(3):
    if sum(a[i])==0:
        ans = True
        break
    if (a[0][i]+a[1][i]+a[2][i])==0:
        ans = True
        break
if (a[0][0]+a[1][1]+a[2][2])==0:
    ans = True

if (a[0][2]+a[1][1]+a[2][0])==0:
    ans = True

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

Submission status: Wrong Answer

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

    n = int(input())

    b = [None]*n
    for i in range(n):
        b[i] = int(input())
    
    #print(a)
    #print(b)

    check = [[False for i in range(3)] for j in range(3)]
    #print(check)
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
              #print("a{}{}={} in b".format(i,j,a[i][j]))
              check[i][j] = True

    for i in range(3):
        if check[i] == [True]*3:
            print("Yes")
            return
        if [row[i] for row in a] == [True]*3:
            print("Yes")
            return

    if [check[0][0],check[1][1],check[2][2]] == [True]*3:
        print("Yes")
        return
    if [check[0][2],check[1][1],check[2][0]] == [True]*3:
        print("Yes")
        return
    print("No")

main()

Submission status: Wrong Answer

Solution code:
inputgrid1 = input().split(" ")
inputgrid2 = input().split(" ")
inputgrid3 = input().split(" ")
num = int(input())
bingolist = list()
length = 0
for i in range (0, num):
    bingolist.append(input())
inputlist = list()
for i in inputgrid1:
    inputlist.append(i)
for i in inputgrid2:
    inputlist.append(i)
for i in inputgrid3:
    inputlist.append(i)
length = len(inputlist) + num
for i in bingolist:
    inputlist.append(i)
inputlist = set(inputlist)
if len(inputlist) == length:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
A = [[],[],[]]
b = []

for i in range(0,3):
    A[i] = [int(x) for x in input().split(" ")]
N = int(input())
for i in range(0,N):
  b.append(int(input()))

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

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

Submission status: Wrong Answer

Solution code:
a = []
b = []
c = [[-1]*3]*3
for i in range(3):
    ai = list(map(int, input().split()))
    a.append(ai)
n = int(input())
for i in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                c[i][j] = 0

chk = 0
for i in range(3):
    if c[i][0:3] == 0 and chk == 0:
        print("Yes")
        chk = 1
        break
if chk == 0:
    for i in range(3):
        if c[0:3][i] == 0 and chk == 0:
            print("Yes")
            chk = 1
            break
if chk == 0:
    if c[0][0] == 0 and c[1][1] == 0 and c[2][2] == 0:
        print("Yes")
    elif c[0][2] == 0 and c[1][1] == 0 and c[2][0] == 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
A = [input().split() for l in range(3)]
N = int(input())
b = list()
for i in range(N):
  b1 = int(input())
  b.append(b1)
ans = [[0] * 3] * 3
for i in range(N):
  for j in range(3):
    for k in range(3):
      if(int(A[j][k]) == b[i]):
        ans[j][k] = 1 
cnt = 0
for i in range(3):
  if(ans[i][0] == 1 and ans[i][1] == 1 and ans[i][2] == 1):
    cnt = 1
  elif(ans[0][i] == 1 and ans[1][i] == 1 and ans[2][i] == 1):
    cnt = 1

if(ans[0][0] ==  1 and ans[1][1] == 1 and ans[2][2] == 1):
  cnt = 1
elif(ans[2][0] == 1 and ans[1][1] == 1 and ans[0][2] == 1):
  cnt = 1
  
if(cnt == 1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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


columns = []
for k in range(3):
    column = [rows[l][k] for l in range(3)]
    columns.append(column)

left = []
for m in range(3):
    left.append(rows[m][m])

right = []
for n in range(3):
    for o in range(3)[::-1]:
        right.append(rows[n][o])

N = int(input())
choice = []
for j in range(N):
    choice.append(int(input()))


matches = []
for row in rows:
    matches.append([c for c in choice if c in row])

for column in columns:
    matches.append([c for c in choice if c in column])

matches.append([c for c in choice if c in left])
matches.append([c for c in choice if c in right])


for match in matches:
    if (len(matches) == 3):
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())    
A3_1,A3_2,A3_3 = map(int, input().split())
N = int(input())
B = []
for _ in range(N):
    B.append(input())

a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

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

  N_list = []
  N = int(input())
  for i in range(N):
    N_list.append(int(input()))
  
  for i in N_list:
    for j in range(3):
      for k in range(3):
        if A[j][k] == i:
          A[j][k] = 0
        else:
          pass


  flag = False

  for i in range(3):
    if A[i][0] + A[i][1] + A[1][2] == 0:
      flag = True

  sum_1 = 0 
  for i in range(3):
    sum_1 += A[i][0]
  if sum_1 == 0:
    flag = True

  sum_2 = 0 
  for i in range(3):
    sum_2 += A[i][1]
  if sum_2 == 0:
    flag = True  

  sum_3 = 0 
  for i in range(3):
    sum_3 += A[i][2]
  if sum_3 == 0:
    flag = True

  naname1 = A[0][0] + A[1][1] + A[2][2]
  if naname1 == 0:
    flag = True

  naname2 = A[0][2] + A[1][1] + A[2][0]
  if naname2 == 0:
    flag = True
  
  if flag == True:
    print('Yes')
  else:
    print('No')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

data = np.array([input().split() for i in range(3)])
data = data.astype(np.int64)

N = int(input())

ans = 0
for i in range(N):
	check = 0
	num = int(input())
	for x in range(3):
		for y in range(3):
			if num == data[x][y]:
				data[x][y] = -1
				break
		if check == 1:
			break

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

Submission status: Wrong Answer

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())    
A3_1,A3_2,A3_3 = map(int, input().split())
N = int(input())
B = []
for _ in range(N):
    B.append(input())

Submission status: Wrong Answer

Solution code:
def get(A, ar, ac):
    if ar > 2 or ar < -2 or ac > 2 or ar < -2:
        return 0
    return A[ar][ac]

def check(A, ar, ac):
    if 0 == get(A, ar-1, ac-1) and 0 == get(A, ar-2, ac-2) and 0 == get(A, ar+1, ac+1) and 0 == get(A, ar+2, ac+2):
        return True
    if 0 == get(A, ar+1, ac-1) and 0 == get(A, ar+2, ac-2) and 0 == get(A, ar-1, ac+1) and 0 == get(A, ar-2, ac+2):
        return True
    if 0 == get(A, ar+1, ac) and 0 == get(A, ar+2, ac) and 0 == get(A, ar-1, ac) and 0 == get(A, ar-2, ac):
        return True
    if 0 == get(A, ar, ac+1) and 0 == get(A, ar, ac+2) and 0 == get(A, ar, ac-1) and 0 == get(A, ar, ac-2):
        return True
    return False

A = [[0 for i in range(3)] for i in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for n in range(N):
    b = int(input())
    for ar in range(3):
        for ac in range(3):
            if A[ar][ac] == b:
                A[ar][ac] = 0
                if check(A, ar, ac):
                    print("Yes")
                    print(A)
                    import sys
                    sys.exit(0)
                continue
print("No")
print(A)

Submission status: Wrong Answer

Solution code:
bingo = []
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
matched = [[False for _ in range(3)] for _ in range(3)]
N = int(input())
for n in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                matched[i][j] = True
is_bingo = False
if matched[0][0] and matched[1][1] and matched[2][2]:
    is_bingo = True
if matched[0][0] and matched[0][1] and matched[0][2]:
    is_bingo = True
if matched[1][0] and matched[1][1] and matched[1][2]:
    is_bingo = True
if matched[2][0] and matched[2][1] and matched[2][2]:
    is_bingo = True
if matched[0][0] and matched[1][0] and matched[2][0]:
    is_bingo = True
if matched[0][1] and matched[1][1] and matched[2][1]:
    is_bingo = True
if matched[0][2] and matched[1][2] and matched[2][2]:
    is_bingo = True
if is_bingo:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A1 = [0] * 3
A2 = [0] * 3
A3 = [0] * 3
for i in range(3):
    A1[i], A2[i], A3[i] = map(int, input().split())

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

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 'ok'
        elif A2[j] == i:
            A2[j] = 'ok'
        elif A3[j] == i:
            A3[j] = 'ok'

for j in range(3):
    if j == 0:
        if A1[j] == A1[j+1] == A1[j+2]:
            print('Yes')
            break
        elif A2[j] == A2[j+1] == A2[j+2]:
            print('Yes')
            break
        elif A3[j] == A3[j+1] == A3[j+2]:
            print('Yes')
            break
        elif A1[j] == A2[j+1] == A3[j+2]:
            print('Yes')
            break
        elif A3[j] == A2[j+1] == A1[j+2]:
            print('Yes')
            break
        elif A1[j] == A2[j] == A3[j]:
            print('Yes')
            break
    if A1[j] == A2[j] == A3[j]:
        print('Yes')
        break
    else:
        print('No')
        break

Submission status: Wrong Answer

Solution code:
A1,A2,A3=map(int, input().split())
A4,A5,A6=map(int, input().split())
A7,A8,A9=map(int, input().split())
N=int(input()) 
b = [int(input()) for _ in range(N)]
cnt1=0
cnt2=0
cnt3=0
cnt4=0
cnt5=0
cnt6=0
cnt7=0
cnt8=0
cnt9=0
for i in range(N):
	if b[i]==A1:
		cnt1+=1
	elif b[i]==A2:
		cnt2+=1
	elif b[i]==A3:
		cnt3+=1
	elif b[i]==A4:
		cnt4+=1
	elif b[i]==A5:
		cnt5+=1
	elif b[i]==A6:
		cnt6+=1
	elif b[i]==A7:
		cnt7+=1
	elif b[i]==A8:
		cnt8+=1
	elif b[i]==A9:
		cnt9+=1
yes=0
if cnt1!=0:
	if (cnt2!=0 and cnt3!=0)or(cnt4!=0 and cnt7!=0)or(cnt5!=0 and cnt9!=0):
		yes+=1
elif cnt2!=0:
	if (cnt5!=0 and cnt8!=0):
		yes+=1
elif cnt3!=0:
	if (cnt6!=0 and cnt9!=0)or(cnt5!=0 and cnt7!=0):
		yes+=1
elif cnt4!=0:
	if (cnt5!=0 and cnt6!=0):
		yes+=1
elif cnt7!=0:
	if (cnt8!=0 and cnt9!=0):
		yes+=1
if yes!=0:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

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

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

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

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

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


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