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:
import sys

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

N = int(input())
numbers = set()
for i in range(N):
    numbers.add(int(input()))


def checker(s):
    if len(s) == 1 and 'x' in s:
        print('Yes')
        sys.exit()


for i in range(3):
    for j in range(3):
        if card[i][j] in numbers:
            card[i][j] = 'x'

# checks to see if the rows
for row in card:
    s = set()
    for col in row:
        s.add(col)
    checker(s)

# checks to see if the columns
for i in range(3):
    s = set()
    for j in range(3):
        s.add(card[j][i])
        checker(s)
# diagonals
s = set()
for i in range(3):
    s.add(card[i][i])
checker(s)

a = set()
a.add(card[0][2])
a.add(card[1][1])
a.add(card[2][0])
checker(a)


print('No')

Submission status: Wrong Answer

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

while True:
  try:
    b = int(input())
    for i in range(3):
      for j in range(3):
        if a[i][j] == b:
          a[i][j] = 0
  except EOFError:
    break

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

if a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = 'No'

    C = [[0 for i in range(3)] for j in range(3)]

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

    for i in range(3):
        if C[i] == [1,1,1]:
            res = 'Yes'
        temp = [C[0][i],C[1][i],C[2][i]]
        if temp == [1,1,1]:
            res == 'Yes'

    temp1 = [C[0][0],C[1][1],C[2][2]]
    temp2 = [C[0][2],C[1][1],C[2][0]]

    if temp1 == [1,1,1]:
        res = 'Yes'
    if temp2 == [1,1,1]:
        res = 'Yes'

    print(res)



main()

Submission status: Wrong Answer

Solution code:
bingo = []
checklists = []
for i in range(3):
  lists = list(map(int,input().split()))
  bingo.append(lists)
num = int(input())
for i in range(num):
  checklists.append(int(input()))
for i in range(3):
  for j in range(3):
    if bingo[i][j] in checklists:
        bingo[i][j] = 0
result = "No"
for i in range(3):
  yoko = 0
  tate = 0
  for k in range(3):  
    if bingo[i][k] == 0:
      yoko += 1
    if bingo[k][i] == 0:
      tate += 1
  if (yoko or tate) == 3:
    result = "Yes"
naname1 = 0
naname2 = 0
for i in range(3):
  if bingo[i][i] == 0:
    naname1 += 1
  if bingo[i][2-i] == 0:
    naname2 += 1
if (naname1 or naname2) == 3:
  result = "Yes"
print(result)

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

y = 0
for kumi in all:
	chk = 0
	for i in range(3):
		for n in b:
			if kumi[i] == n:
				chk += 1
	if chk == 3:
		print("Yes")
		y = 1
	break

if y == 0:
	print("No")

Submission status: Wrong Answer

Solution code:
#python3

def main():
    a = []
    for _ in range(3):
        x, y, z = map(int, input().split())
        a.append((x, y, z))
    n = int(input())
    b =[]
    for _ in range(n):
        b.append(int(input()))

    g = [[0 for _ in range(3)] for _ in range(3)]
    for i in range(3):
        for j in range(3):
            flag = False
            for k in range(n):
                if a[i][j] == b[k]:
                    flag = True
            if flag:
                g[i][j] = 1
    
    bingo = False
    for i in range(3):
        flag = True
        if g[i][i] != 1:
            flag = False
        if flag:
            bingo = True            

    for i in range(3):
        flag = True
        if g[2-i][2-i] != 1:
            flag = False  
        if flag:
            bingo = True

    for i in range(3):
        if sum(g[i]) == 3:
            bingo = True

    if (g[0][0] + g[1][0] + g[2][0] == 3):
        bingo = True
    
    if (g[0][1] + g[1][1] + g[2][1] == 3):
        bingo = True
    
    if (g[0][2] + g[1][2] + g[2][2] == 3):
        bingo = True

    if bingo:
        print('Yes')
    else:
        print('No')
main()

Submission status: Wrong Answer

Solution code:
A11,A12,A13 = map(int,input().split())
A21,A22,A23 = map(int,input().split())
A31,A32,A33 = map(int,input().split())
A = [[A11,A12,A13],[A21,A22,A23],[A31,A32,A33]]
N = int(input())
b_i = list([int(input()) for _ in range(N)])

for bi in b_i:
    for i in range(3):
        for j in range(3):
            if A[i][j] == bi:
                A[i][j] = 'on'
flag_no_bingo = False
#縦調査
for j in range(3):
    if A[0][j] == 'on':
        if A[1][j] == 'on' and A[2][j] == 'on':
            flag_no_bingo = True
#横調査
for i in range(3):
    if A[i][0] == 'on':
        if A[i][1] == 'on' and A[i][2] == 'on':
            flag_no_bingo = True
#斜め調査
if A[0][0] == 'on' and A[1][1] and A[2][2]:
    flag_no_bingo = True
if A[0][2] == 'on' and A[1][1] and A[2][0]:
    flag_no_bingo = True
#結果出力
if flag_no_bingo == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
maru=111
flag=0
n=int(input())
for k in range(0,n):
    e=int(input())
    for i in range(0,3):    
        if e==a[i]:
            a[i]=maru
        if e==b[i]:
            b[i]=maru
        if e==c[i]:
            c[i]=maru

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

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

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


print(a)
print(b)
print(c)

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

Submission status: Wrong Answer

Solution code:
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst3 = list(map(int, input().split()))
bng1=[0, 0, 0]
bng2=[0, 0, 0]
bng3=[0, 0, 0]
n = int(input())
for i in range(n):
    b = int(input())
    for i in range(3):
        if b == lst1[i]:
            bng1[i] = 1
            break
        if b == lst2[i]:
            bng2[i] = 1
            break
        if b == lst3[i]:
            bng3[i] = 1
            break
    if '0' in bng1 == False or '0' in bng2 == False or '0' in bng3 == False:
        print('Yes')
        exit()
    elif bng1[0] * bng2[1] * bng3[2] != 0 or  bng1[2] * bng2[1] * bng3[0] != 0:
        print('Yes')
        exit()
    elif bng1[0] * bng2[0] * bng3[0] != 0 or  bng1[1] * bng2[1] * bng3[1] != 0 or  bng1[2] * bng2[2] * bng3[2] != 0:
        print('Yes')
        exit()

print('No')

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(frag == True):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
bingo = []
checklists = []
for i in range(3):
  lists = list(map(int,input().split()))
  bingo.append(lists)
num = int(input())
for i in range(num):
  checklists.append(int(input()))
for i in range(3):
  for j in range(3):
    if bingo[i][j] in checklists:
        bingo[i][j] = 0
print(bingo)
result = "No"
for i in range(3):
  yoko = 0
  tate = 0
  for k in range(3):  
    if bingo[i][k] == 0:
      yoko += 1
    if bingo[k][i] == 0:
      tate += 1
  print(yoko,tate)
  if (yoko or tate) == 3:
    result = "Yes"
naname1 = 0
naname2 = 0
for i in range(3):
  if bingo[i][i] == 0:
    naname1 += 1
  if bingo[i][2-i] == 0:
    naname2 += 1
print(naname1,naname2)
if (naname1 or naname2) == 3:
  result = "Yes"
print(result)

Submission status: Wrong Answer

Solution code:
import sys

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

N = int(input())
numbers = set()
for i in range(N):
    numbers.add(int(input()))


def checker(s):
    if len(s) == 1 and 'x' in s:
        print('Yes')
        sys.exit()


for i in range(3):
    for j in range(3):
        if card[i][j] in numbers:
            card[i][j] = 'x'

# checks to see if the rows
for row in card:
    s = set()
    for col in row:
        s.add(col)
    checker(s)

# checks to see if the columns
for i in range(3):
    for j in range(3):
        s = set()
        s.add(card[j][i])
        checker(s)
# diagonals
s = set()
for i in range(3):
    s.add(card[i][i])
checker(s)

a = set()
a.add(card[0][2])
a.add(card[1][1])
a.add(card[2][0])
checker(a)
    

print('No')

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a.extend(a2)
a.extend(a3)
n = int(input())
b = list(map(int, [input() for i in range(n)]))
bo = []
for i in a:
  isChange=False
  for j in b:
    if i==j:
      bo.append(True)
      isChange=True
      break
  if not isChange:
    bo.append(False)
if bo[0] and bo[1] and bo[2]:
  print('YES')
elif bo[3] and bo[4] and bo[5]:
  print('YES')
elif bo[6] and bo[7] and bo[8]:
  print('YES')
elif bo[0] and bo[3] and bo[6]:
  print('YES')
elif bo[1] and bo[4] and bo[7]:
  print('YES')
elif bo[2] and bo[5] and bo[8]:
  print('YES')
elif bo[0] and bo[4] and bo[8]:
  print('YES')
elif bo[3] and bo[4] and bo[6]:
  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
    elif j >= 1:
        if A1[j] == A2[j] == A3[j]:
            print('Yes')
            break
    else:
        print('No')
        break

Submission status: Wrong Answer

Solution code:
arr = []
ans = []
for i in range(3):
  arr.extend(list(map(int,input().split())))
N = int(input())
for j in range(N):
  num = int(input())
  if num in arr:
    ans.append(arr.index(num))
if ([0,1,2]<=ans)or([3,4,5]<=ans)or([6,7,8]<=ans)or([0,3,6]<=ans)or([1,4,7]<=ans)or([2,5,8]<=ans)or([0,4,8]<=ans)or([2,4,6]<=ans):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l=[[]]*3
for k in range(3):
  l[k]=list(map(int,input().split()))
n=int(input())
ll=[[0,0,0]]*3
for k in range(n):
  i=int(input())
  for j in range(3):
    if i in l[j]:
      ll[j][l[j].index(i)]=1
a=0
if ll[0][0]==1:
  if ll[0][1]==1 and ll[0][2]==1:
    print("Yes")
    a=1
  elif ll[1][1]==1 and ll[2][2]==1:
    print("Yes")
    a=1
  elif ll[1][0]==1 and ll[2][0]==1:
    print("Yes")
    a=1
if a==1:
  pass
elif ll[0][1]==1 and ll[1][1]==1 and ll[2][1]==1:
  print("Yes")
  a=1
if a==1:
  pass
elif ll[0][2]==1:
  if ll[1][1]==1 and ll[2][0]==1:
    print("Yes")
    a=1
  elif ll[1][2]==1 and ll[2][2]==1:
    print("Yes")
    a=1
if a==1:
  pass
elif ll[1][0]==1:
  if ll[1][1]==1 and ll[1][2]==1:
    print("Yes")
    a=1
if a==1:
  pass
elif ll[2][0]==1:
  if ll[2][1]==1 and ll[2][2]==1:
    print("Yes")
    a=1
if a==0:
  print("No")

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()]
# print(A1)
# print(A2)
# print(A3)

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
    elif b in A2:
        A2[A2.index(b)] = 0
    elif 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:
A,B,C=map(int,input().split())
D,E,F=map(int,input().split())
G,H,I=map(int,input().split())
N=int(input())
b=[input() for i in range(N)]
if b.count(A)>0 and b.count(B)>0 and b.count(C)>0:
    print("Yes")
    exit()
if b.count(D)>0 and b.count(E)>0 and b.count(F)>0:
    print("Yes")
    exit()
if b.count(G)>0 and b.count(H)>0 and b.count(I)>0:
    print("Yes")
    exit()
if b.count(A)>0 and b.count(D)>0 and b.count(G)>0:
    print("Yes")
    exit()
if b.count(B)>0 and b.count(E)>0 and b.count(H)>0:
    print("Yes")
    exit()
if b.count(C)>0 and b.count(F)>0 and b.count(I)>0:
    print("Yes")
    exit()
if b.count(A)>0 and b.count(E)>0 and b.count(I)>0:
    print("Yes")
    exit()
if b.count(C)>0 and b.count(E)>0 and b.count(G)>0:
    print("Yes")
    exit()
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
l,m,k = map(int, input().split())
g = [a, b, c, d, e, f, l, m, k]
lis1 = []
n = int(input())
for i in range(n):
    op = int(input())
    lis1.append(op)
    
if lis1 == [a,b,c] or lis1 == [d,e,f] or lis1 == [l,m,k] or lis1 == [a,d,l] or lis1 == [b,e,m] or lis1 == [c,f,k] or lis1 == [a,e,k] or lis1 == [c,e,l]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a1=[int(x) for x in input().split()]
a2=[int(x) for x in input().split()]
a3=[int(x) for x in input().split()]
n=int(input())
b=set()
for c in range(n):
    b.add(int(input()))
t=list(range(8))
t[1]=set(a1)
t[2]=set(a2)
t[3]=set(a3)
t[4]={a1[0],a2[0],a3[0]}
t[5]={a1[1],a2[1],a3[1]}
t[6]={a1[2],a2[2],a3[2]}
t[7]={a1[0],a2[1],a3[2]}
t[0]={a1[0],a2[1],a3[0]}

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

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
bingo = False
print(A[1][1])
for i in range(N):
    for x in range(3):
        for y in range(3):
            if A[x][y] == b[i]:
                A[x][y] = 0
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        bingo =True
for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        bingo =True
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
        bingo =True 
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
        bingo =True             
if bingo :
    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 = list(map(int, input().split()))

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 cal(A):
  for index, a in enumerate(A):
    if a in b:
      A[index] = 0
  return A

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
A1 = cal(A1)
A2 = cal(A2)
A3 = cal(A3)
bingo = "No"
if sum(A1)==0 or sum(A2)==0 or sum(A3)==0 or A1[0]+A2[0]+A3[0]==0 or A1[1]+A2[1]+A3[1]==0 or A1[2]+A2[2]+A3[2]==0 or A1[0]+A2[1]+A3[2]==0 or A1[2]+A2[1]+A1[0]==0:
  bingo = "Yes"

print(bingo)

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")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()
N=int(input())
numbers=[input() for i in range(N)]



for n in numbers:
    if a==n:
        a=0
    elif b==n:
        b=0
    elif c==n:
        c=0
    elif d==n:
        d=0
    elif e==n:
        e=0
    elif f==0:
        f=0
    elif g== n:
        g = 0
    elif h == n:
        h = 0
    elif i == n:
        i = 0
    else:
        continue

if a==b==c or d==e==f or g==h==i or a==d==g or b==e==h or c==f==i or a==e==i or c==e==g:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

while True:
  try:
    b = int(input())
    for i in range(3):
      for j in range(3):
        if a[i][j] == b:
          a[i][j] = 0
  except EOFError:
    break

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

if a[0][0]+a[1][1]+a[2][2] == 0 or a[2][0]+a[1][1]+a[0][2] == 0:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
b = [0] * 9


def hantei():
    for i in range(3):
        if b[i * 3] == 1 and b[i * 3 + 1] == 1 and b[i * 3 + 2] == 1:
            return True
    for i in range(3):
        if b[i] == 1 and b[i + 3] == 1 and b[i + 6] == 1:
            return True
    if b[0] == 1 and b[4] == 1 and b[8] == 1:
        return True
    if b[2] == 1 and b[5] == 1 and b[6] == 1:
        return True
    return False


a = [0] * 9
[a[0], a[1], a[2]] = input().split()
[a[3], a[4], a[5]] = input().split()
[a[6], a[7], a[8]] = input().split()
a = [int(i) for i in a]

n = int(input())

for i in range(n):
    c = int(input())
    for j in range(len(a)):
        if a[j] == c:
            b[j] = 1

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

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))
A += list(map(int, input().split()))
A += list(map(int, input().split()))
bingo = [0]*9
N = int(input())

for i in range(N):
    try:
        idx = A.index(int(input()))
        bingo[idx] = 1
    except:
        pass

for j in range(3):
    if sum(bingo[j*3:(j+1)*3]) == 3: print('Yes'); exit()
    if sum([bingo[j*3], bingo[j*3+1], bingo[j*3+2]]) == 3: print('Yes'); exit()
if sum([bingo[0], bingo[4], bingo[8]]) == 3: print('Yes'); exit()
if sum([bingo[2], bingo[4], bingo[6]]) == 3: print('Yes'); exit()
print('No')

Submission status: Wrong Answer

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
A = A_1 + A_2 + A_3
N = int(input())
B = []
for _ in range(N):
  B.append(int(input()))
for b in range(len(B)):
  for a in range(len(A)):
    if B[b] == A[a]:
      A[a] = 0
BINGO = 'No'
for i in range(3):
  if A[i*3] + A[i*3+1] + A[i*3+2] == 0:
    BINGO = 'Yes'
for j in range(3):
    if A[i] + A[i+3] + A[i+6] == 0:
      BINGO = 'Yes'
if (A[0] + A[4] + A[8] == 0):
  BINGO = 'Yes'
if (A[2] + A[4] + A[6] == 0):
  BINGO = 'Yes'
print(BINGO)

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=int(input())
A = []
for i in range(n):
    A.append(int(input()))
if ((a in A) and (b in A) and (c in A)) or ( d in A and e in A and f in A) or(g in A and h in A and i in A) or (a in A and d in A and g in A) or (b in A and e in A and h in A) or(c in A and f in A and i in A) or ( a in A and e in A and i in A) or(c in A and e in A and g in A):


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

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(frag == True):
    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)

Submission status: Wrong Answer

Solution code:
a1_list = list(map(int, input().split()))
a2_list = list(map(int, input().split()))
a3_list = list(map(int, input().split()))
a1_list.extend(a2_list)
a1_list.extend(a3_list)

n = int(input())
nums = []
for _ in range(n):
  x = int(input())
  nums.append(x)
  
result = "No"
patterns = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [3, 4, 6]]
for p in patterns:
  if a1_list[p[0]] in nums and a1_list[p[1]] in nums and a1_list[p[2]] in nums:
    result = "Yes"
    break
print(result)

Submission status: Wrong Answer

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

N = int(input())

c_1=[0,0,0]
c_2=[0,0,0]
c_3=[0,0,0]
b = []

count = 0

for i in range(N):
    b.append(int(input()))
    
for i in range(N):
    for j in range(3):
        if b[i] == a_1[j]:
            c_1[j] = 1
        if b[i] == a_2[j]:
            c_2[j] = 1
        if b[i] == a_3[j]:
            c_3[j] = 1
            
if c_1[0] == 1 and c_1[1] == 1 and c_1[2]:
    count += 1
if c_2[0] == 1 and c_2[1] == 1 and c_2[2]:
    count += 1
if c_3[0] == 1 and c_3[1] == 1 and c_3[2]:
    count += 1
if c_1[0] == 1 and c_2[0] == 1 and c_3[0]:
    count += 1
if c_1[1] == 1 and c_2[1] == 1 and c_3[1]:
    count += 1
if c_2[2] == 1 and c_2[2] == 1 and c_3[2]:
    count += 1
if c_1[0] == 1 and c_2[1] == 1 and c_3[2]:
    count += 1
if c_1[2] == 1 and c_2[1] == 1 and c_3[0]:
    count += 1


#print(c_1)
#print(c_2)
#print(c_3)
#print(count)

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

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
maru=111
flag=0
n=int(input())
for k in range(0,n):
    e=int(input())
    for i in range(0,3):    
        if e==a[i]:
            a[i]=maru
        if e==b[i]:
            b[i]=maru
        if e==c[i]:
            c[i]=maru

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

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

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


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

Submission status: Wrong Answer

Solution code:
import collections as c
import sys
input = sys.stdin.readline
ip = lambda : map(int, input().split())
mod = 10**9+7
# ##############
A = []
for i in range(3):
    A.append(list(ip()))
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)
if sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[2]) == 0 or (A[0][0] + A[1][0] + A[2][0] == 0) or (A[0][1] + A[1][1] + A[2][1] == 0) or (A[0][2] + A[1][2] + A[2][2] == 0) or (A[0][0] + A[1][1] + A[2][2] == 0) or (A[0][2] + A[1][1] + A[2][0] == 0):
    print('Yes')
else:print('No')

Submission status: Wrong Answer

Solution code:
def main(a: list, n: int, b: list):
    res = [[False, False, False], [False, False, False], [False, False, False]]
    for b in b:
        for i, a_row in enumerate(a):
            for j, a_col in enumerate(a_row):
                if b == a_col:
                    res[i][j] = True

    # row
    for r in res:
        if False not in r:
            print("Yes")
            return

    for i in range(3):
        for j in range(3):
            if False not in [res[i][0], res[i][1], res[i][2]]:
                print("Yes")
                return
        # cross

        if False not in [res[i][i], res[i][i], res[i][i]]:
            print("Yes")
            return
        if False not in [res[2 - i][2 - i], res[2 - i][2 - i], res[2 - i][2 - i]]:
            print("Yes")
            return

    print("No")


if __name__ == "__main__":
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]

    main(a, n, b)

Submission status: Wrong Answer

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

b = []
for i in range(n):
    b_ = int(input())
    b.append(b_)
# print(a)
# print(b)
for i in range(3):
    for k in range(3):
        for j in range(n):
                if a[i][k] == b[j]:
                    a[i][k] = 'ok'

conc = []

for i in range(3):
    for j in range(3):
        s = [i,j]
        if a[i][j] == 'ok':
            conc.append(s)

# print(a)
# print(conc)
x = []
y = []

if conc == []:
    print('No')
else:
    for i in range(len(conc)):
        x.append(conc[i][0])
        y.append(conc[i][1])
    # print(x)
    # print(y)

    if (len(set(x)) or len(set(y))) == 3 and (len(set(x)) and len(set(y))) != 2:
        print('Yes')
    elif (len(set(x)) and len(set(y))) == 3:
        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



for kumi in all:
	for i in range(3):
		chk = 0
		if kumi[i] in b:
			chk += 1
		if chk == 3:
			print("Yes")
		break
	if chk == 3:
		break

if chk != 3:
	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 and A_2[0] in B_list and A_3[0] in B_list:
    ans = "Yes"
elif A_1[0] in B_list and A_1[1] in B_list and A_1[2] in B_list:
    ans = "Yes"
elif A_1[0] in B_list and 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)