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:
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
l=[]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i]==a[j][k]:
        l.append([j+1,k+1])
if len(l)>=6:
  print('Yes')
elif len(l)<=2:
  print('No')
elif len(l)==3:
  ll= sorted(l, key=lambda x: x[0])
  lll=sorted(l, key=lambda x: x[1])
  if ll[0][0]==ll[2][0] or lll[0][0]==lll[2][1]:
    print('Yes')
  else:
    print('No')
else:
  if l.count([1,1])==l.count([2,2])==l.count([3,3])==1 or l.count([1,3])==l.count([2,2])==l.count([3,1])==1:
    print('Yes')
  else:
    count1,count2=0,0
    for i in range(len(l)-1):
      if l[i][0]==l[i+1][0]:
        count1+=1
      if l[i][1]==l[i+1][1]:
        count2+=1
    if count1==3 or count2==3:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

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

for i in range(3):
    b = input().split()
    for j in range(3):
        lists[i][j] = int(b[j])
N = int(input())

for i in range(N):
    c = int(input())
    for j in range(3):
        for k in range(3):
            if lists[j][k] == c:
                lists[j][k] = 0

for i in range(3):
    if lists[i][0]+lists[i][1]+lists[i][2] == 0:
        print('Yes')
        break
    elif lists[0][i]+ lists[1][i] + lists[2][i] == 0:
        print('Yes')
        break
    elif lists[0][0]+lists[1][1]+lists[2][2] == 0:
        print('Yes')
        break
    elif lists[0][2]+ lists[1][1] + lists[2][0] == 0:
        print('Yes')
        break
    else:
        print('No')
        break

Submission status: Wrong Answer

Solution code:
a = []
b = []
c = [[-1]*3]*3
s = set()
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):
    for j in range(3):
        if c[i][j] == 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 = []
bingo = []
for i in range(3):
    A.append(list(map(int, input().split())))
    bingo.append([False] * 3)

N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            idx = A[j].index(b)
            bingo[j][idx] = True

# check
migiue = True
migisita = True
okFlg = False
for i in range(3):
    tate = True
    yoko = True
    for j in range(3):
        if bingo[i][j] == False:
            yoko = False
        if bingo[j][i] == False:
            tate = False
    if tate or yoko:
        okFlg = True
        break
    if bingo[i][i] == False:
        migisita = False
    if bingo[-i - 1][-i - 1] == False:
        migiue = False

if migiue or migisita:
    if okFlg == False:
        okFlg = True
print('YNeos'[not okFlg::2])

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-1)]
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:
def main():
    A = [list(map(int,input().split(" "))) for i in range(3)]
    N = int(input())
    b_list = [int(input()) for _ in range(N)]

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

    flag = False
    for i in range(3):
        for j in range(3):
                if(j+2 < 3 and A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j+2 < 3 and A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
                if(i - 2 > 0 and j-2 > 0 and A[i][j] == 0 and A[i-1][j-1] == 0 and A[i-2][j-2] == 0):
                    flag = True
                    break
        if(flag):
            break

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
line1 = input().split(" ")
line2 = input().split(" ")
line3 = input().split(" ")

result1 = []
result2 = []
result3 = []

for i in range(3):
  result1.append("0")
  result2.append("0")
  result3.append("0")

call_sum = int(input())

for j in range(call_sum):
  call_num = int(input())
  for i in range(3):
    if call_num == int(line1[i]):
      result1[i] = "1"
      break
    if call_num == int(line2[i]):
      result2[i] = "1"
      break
    if call_num == int(line3[i]):
      result3[i] = "1"
      break
while(1):
  if result1[0] == result1[1] == result1[2] == "1" or result2[0] == result2[1] == result2[2] == "1" or result3[0] == result3[1] == result3[2] == "1":
    print("Yes")
    break
  elif result1[0] == result2[1] == result3[2] == "1" or result1[2] == result2[1] == result3[0] == "1":
    print("Yes")
    break
  for j in range(3):
    end_flg = False
    if result1[i] == result2[i] == result3[i] == "1":
      print("Yes")
      end_flg = True
      break
  if end_flg:
    break
  print("No")
  break

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())
b=[int(input()) for i in range(N)]

B=[A1[0], A2[1], A3[2]]
C=[A1[2], A1[1], A3[0]]
D=[A1[0], A2[0], A3[0]]
E=[A1[1], A2[1], A3[1]]
F=[A1[2], A2[2], A3[2]]


answer='No'
if len(set(A1) & set(b))>2:
  answer='Yes'
if len(set(A2) & set(b))>2:
  answer='Yes'
if len(set(A3) & set(b))>2:
  answer='Yes'
if len(set(B) & set(b))>2:
  answer='Yes'
if len(set(C) & set(b))>2:
  answer='Yes'
if len(set(D) & set(b))>2:
  answer='Yes'
if len(set(E) & set(b))>2:
  answer='Yes'
if len(set(F) & set(b))>2:
  answer='Yes'
print(answer)

Submission status: Wrong Answer

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

count = 0
while count < N:
    for i in range(0,3):
      for j in range(0,3):
        if b[count] == A[i][j]:
          A[i][j] = 0
    count += 1
            
print(A)
sum_y = [0]*3                
for i in range(0,3):
  for j in range(0,3):
    sum_y[i] += A[i][j]#横

sum_t = [0]*3
for i in range(0,3):
  for j in range(0,3):
    sum_t[i] += A[j][i]
    

sum1 = A[0][0] + A[1][1] + A[2][2]
sum2 = A[0][2] + A[1][1] + A[0][2]

if sum_y[0] == 0:
    print("Yes")
elif sum_y[1] == 0:
    print("Yes")
elif sum_y[2] == 0:
    print("Yes")
elif sum_t[0] == 0:
    print("Yes") 
elif sum_t[1] == 0:
    print("Yes") 
elif sum_t[2] == 0:
    print("Yes") 
elif sum1 == 0:
  print("Yes")
elif sum2 == 0:
  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[1][0] + bingo_map[1][1] + bingo_map[2][1]
    kuromi = bingo_map[2][0] + 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:
import itertools

A = []
A1 = [int(i) for i in input().split()]
A.append(A1)
A2 = [int(i) for i in input().split()]
A.append(A2)
A3 = [int(i) for i in input().split()]
A.append(A3)

f = [[0] * 3 for i in range(3)]

#print(A)


N = int(input ())
b = [input().split() for i in range(N)]
b= list(itertools.chain.from_iterable(b))
b = list(map(int, b))
print(b)

for i in range(3):
    for j in range(3):
        for x in b:
            if A[i][j] == x:
                f[i][j] = 1
s = 0

for i in range(3):
    if sum(f[i]) == 3:
        s = 1
    if f[0][0] + f[1][1] + f[2][2] == 3:
        s = 1
    if f[0][2] + f[1][1] + f[2][0] == 3:
        s = 1
    for j in range(3):
        if f[0][j] + f[1][j] + f[2][j] == 3:
            s = 1
        
                
        
if s == 1:
    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] = [int(j) for j in input().split()]

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


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

f = 0
for i in range(3):
    if sum(a[i]) == 0:
        f = 1
        break

for i in range(3):
    tmp = 0
    for j in range(3):
        tmp += a[i][j]
    if tmp == 0:
        f = 1
        break

if a[0][0] + a[1][1] + a[2][2] == 0:
    f = 1
if a[0][2] + a[1][1] + a[2][0] == 0:
    f = 1

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

Submission status: Wrong Answer

Solution code:
bingo = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
mas = [[0]*3]*3
ans = []
for m in range(n):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b[m]:
                ans.append([i,j])
for i,j in ans:
    bingo[i][j] = -1
lists = []
cnt = 0

for i in range(3):
    cnt = 0
    for j in range(3):
        if bingo[i][0] == -1:
            cnt = 1
        if bingo[i][1] == -1:
            cnt = 1
        if bingo[i][2] == -1:
            cnt = 1
        if bingo[0][j] == -1:
            cnt = 1
        if bingo[1][j] == -1:
            cnt = 1
        if bingo[2][j] == -1:
            cnt = 1
        if i == 0 and j == 0:
            if bingo[i][j] == -1 and bingo[i+1][j+1] == -1 and bingo[i+2][j+2] == -1:
                cnt = 1
        if i == 0 and j == 2:
            if bingo[i][j] == -1 and bingo[i+1][j-1] == -1 and bingo[i+2][j-2] == -1:
                cnt = 1
if cnt == 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:
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:
	chk = 0
	for i in range(3):
		if kumi[0] in b:
			chk += 1
	if chk == 3:
		print("Yes")
		break

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

Submission status: Wrong Answer

Solution code:
def checkbingo(bingo,bs):
  for b in bingo:
    cnt = 0
    for n in bs:
      if n in b:
        cnt +=1
    if cnt == len(b):
      return True
  return False

list1 = input('').split(' ')
list2 = input('').split(' ')
list3 = input('').split(' ')
bingo = [list1,list2,list3]
bingo.append([list1[0],list2[0],list3[0]])
bingo.append([list1[1],list2[1],list3[1]])
bingo.append([list1[2],list2[2],list3[2]])
bingo.append([list1[0],list1[1],list2[2]])
bingo.append([list1[2],list1[1],list2[0]])
max_n = int(input(''))
bs = []
result = False
for n in range(0,max_n):
  bs.append(input(''))

if checkbingo(bingo,bs):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

    flag = False
    for i in range(3):
        for j in range(3):
                if(j+2 < 3 and A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j+2 < 3 and A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
                if(i-1 > 0 and j-2 > 0 and A[i][j] == 0 and A[i-1][j-1] == 0 and A[i-2][j-2] == 0):
                    flag = True
                    break
        if(flag):
            break

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
A_list1 = list(map(int, input().split()))
A_list2 = list(map(int, input().split()))
A_list3 = list(map(int, input().split()))
N = int(input())
B_list = []
for i in range(N):
    B_list.append(int(input()))

A_list1_c = []
A_list2_c = []
A_list3_c = []
for i in B_list:
    if i in A_list1:
        A_list1_c.append(A_list1.index(i))
    if i in A_list2:
        A_list2_c.append(A_list2.index(i))
    if i in A_list3:
        A_list3_c.append(A_list3.index(i))

for i in A_list1_c:
    if i in A_list2_c and i in A_list3_c:
        print("Yes")
        exit()
    if i == 0:
        if 1 in A_list2_c:
            if 2 in A_list3_c:
                print("Yes")
                exit()
    if i == 2:
        if 1 in A_list2_c:
            if 0 in A_list3_c:
                print("Yes")
                exit()
if sum(A_list1_c) == 3 or sum(A_list2_c) == 3 or sum(A_list3_c) == 3:
    print("Yes")
    exit()

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

for i in range(int(input())):
    try:
        idx = A.index(int(input()))
        bingo[idx] = 1
    except:
        pass
    if i >= 3:
        index = 0
        for j in range(3):
            if sum(bingo[j*3:(j+1)*3]) == 3: print('\nYes'); exit()
            if sum([bingo[j*3], bingo[j*3+1], bingo[j*3+2]]) == 3: print('\nYes'); exit()
        if sum([bingo[0], bingo[4], bingo[8]]) == 3: print('\nYes'); exit()
        if sum([bingo[2], bingo[4], bingo[6]]) == 3: print('\nYes'); exit()

print('No')

Submission status: Wrong Answer

Solution code:
b=[]
c=[0]*9
for i in range(3):
  a=input().split()
  b.append(int(a[0]))
  b.append(int(a[1]))
  b.append(int(a[2]))
N=int(input())
for i in range(N):
  e=int(input())
  for j in range(9):
    if(e==b[j]):
      c[j]=1
if(c[0]==c[1]==c[2]==1):
  print('Yes')
elif(c[3]==c[4]==c[5]==1):
  print('Yes')
elif(c[6]==c[7]==c[8]==1):
  print('Yes')
elif(c[0]==c[4]==c[8]==1):
  print('Yes')
elif(c[2]==c[4]==c[6]==1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = []
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
    
tf = [[False for i in range(3)] for j 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:
                tf[j][k] = True

bingo = 0
for i in range(3):
    if tf[i] == [True, True, True]:
        bingo += 1

for i in range(3):
    if tf[0][i] == True and tf[0][i] == True and tf[0][i] == True:
        bingo += 1

if tf[0][0] == True and tf[1][1] == True and tf[2][2] == True:
    bingo += 1
    
if tf[0][2] == True and tf[1][1] == True and tf[2][0] == True:
    bingo += 1

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  card = []
  bingo = [[0]*3 for _ in range(3)]
  for i in range(3):
    card.append(list(map(int, input().split())))
  n = int(input())
  for _ in range(n):
    b = int(input())
    for i in range(3):
      for j in range(3):
        if card[i][j] == b:
          bingo[i][j]=1

  flag = False
  bingo = numpy.array(bingo)
  for i in range(3):
    if sum(bingo[i]) == 3 or sum(bingo[:,j]):
      flag = True
  l, r = 0, 0
  for i in range(3):
    l += bingo[i,i]
    r += bingo[i, 2-i]
  if l==3 or r==3:
    flag = True
  if flag:
    print('Yes')
  else:
    print('No')

if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
a_list = []
for _ in range(3):
    a = list(map(int, input().split()))
    a_list = a_list + a
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a_list:
        a_list[a_list.index(b)] = 0
    else:
        continue
if a_list[:3] == 0:
    print("Yes")
elif a_list[3:6] == 0:
    print("Yes")
elif a_list[6:] == 0:
    print("Yes")
elif a_list[0] == a_list[3] == a_list[6] == 0:
    print("Yes")
elif a_list[1] == a_list[4] == a_list[7] == 0:
    print("Yes")
elif a_list[2] == a_list[5] == a_list[8] == 0:
    print("Yes")
elif a_list[0] == a_list[4] == a_list[8] == 0:
    print("Yes")
elif a_list[2] == a_list[4] == a_list[6] == 0:
    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

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

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

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.append(int(input()))

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

ans = "NO"
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        ans = "YES"
        break
    if A[0][i] == A[1][i] == A[2][i] == 0:
        ans = "YES"
        break
    if A[0][0] == A[1][1] == A[2][2] == 0:
        ans = "YES"
        break
    if A[0][2] == A[1][1] == A[2][0] == 0:
        ans = "YES"
print(ans)

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)

for i in range(2, -1, -1):
    s.add(card[i][i])
checker(s)

print('NO')

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'
        if [C[0][i],C[1][i],C[2][i]] == [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):
  for k in range(3):
    yoko = 0
    tate = 0
    if bingo[i][k] == 0:
      yoko += 0
    elif bingo[k][i] == 0:
      tate += 0
  if (yoko or tate) == 3:
    result = "Yes"
naname1 = 0
naname2 = 0
for i in range(3):
  if bingo[i][i] == 0:
    naname1 += 1
  elif 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



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

if chk != 3:
	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())
b=[]
for i in range(N):
    b.append(input())
    for j in range(3):
        for k in range(3):
            if(A[j][k]==int(b[i])):
                A[j][k]=0
            else:
                pass
B=[[0 for i in range(3)] for j in range(3)]
C=[[0 for i in range(3)] for j in range(2)]
for i in range(3):
    for j in range(3):
        if(i==j and i!=2):
            C[0][j]=A[i][j]
            B[i][j]=A[i][j]
        elif(i==j and i==2):
            C[0][j]=A[i][j]
            C[1][j]=A[i][j]
            B[i][j]=A[i][j]
        elif((i==0 and j==2) or (i==2 and j==0)):
            C[1][i]=A[i][j]
            B[j][i]=A[i][j]
        else:
            B[j][i]=A[i][j]
count=0
for i in A:
    if(i==[0,0,0]):
        count+=1
    else:
        pass
for i in B:
    if(i==[0,0,0]):
        count+=1
    else:
        pass
for i in C:
    if(i==[0,0,0]):
        count+=1
    else:
        pass
if(count>0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [int(j) for i in range(3) for j in input().split(' ')]
n = int(input())
nn = [int(input()) for i in range(n)]

for ni in nn:
  if ni in a:
    a[a.index(ni)] = 0

    
judge = "Yes"
if a[4]!=0 and a[2]!=0 and a[6]!=0:
  judge = "No"

if a[4]==0:
  if a[2]!=0 and a[6]!=0 and a[1]!=0 and a[7]!=0:
    judge = "No"

print(judge)

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] = 1001
        elif A2[j] == i:
            A2[j] = 1001
        elif A3[j] == i:
            A3[j] = 1001

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

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 = []
for _ in range(n):
    b.append(input())
res = ""
for x in b:
    if int(x) == int(a1[0]):
        res += "1"
    if int(x) == int(a2[1]):
        res += "1"
    if int(x) == int(a3[2]):
        res += "1"
    if int(x) == int(a1[0]):
        res += "2"
    if int(x) == int(a1[1]):
        res += "2"
    if int(x) == int(a1[2]):
        res += "2"
    if int(x) == int(a2[0]):
        res += "3"
    if int(x) == int(a2[1]):
        res += "3"
    if int(x) == int(a2[2]):
        res += "3"
    if int(x) == int(a3[0]):
        res += "4"
    if int(x) == int(a3[1]):
        res += "4"
    if int(x) == int(a3[2]):
        res += "4"
    if int(x) == int(a1[0]):
        res += "5"
    if int(x) == int(a2[0]):
        res += "5"
    if int(x) == int(a3[0]):
        res += "5"
    if int(x) == int(a1[1]):
        res += "6"
    if int(x) == int(a2[1]):
        res += "6"
    if int(x) == int(a3[1]):
        res += "6"
    if int(x) == int(a1[2]):
        res += "7"
    if int(x) == int(a2[2]):
        res += "7"
    if int(x) == int(a3[2]):
        res += "7"
    if int(x) == int(a1[2]):
        res += "8"
    if int(x) == int(a2[1]):
        res += "8"
    if int(x) == int(a3[0]):
        res += "8"
if res == "111" or res == "222" or res == "333" or res=="444" or res=="555" or res=="666" or res=='777' or res =="888":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
a = np.array(a)
for i in range(n):
    a[np.where(a == b[i])] = bool(b[i] in a)
def check(i,j):
    if i >= 0 and i < 3 and j >= 0 and j < 3:
        if a[i][j] == 1:
            return True
    return False
        
for i in range(3):
    for j in range(3):
        if a[i][j] == 1:
            if (check(i+1,j) and check(i+2,j)) or (check(i,j+1) and check(i,j+2)) or (check(i+1,j+1) and check(i+2,j+2)) or (check(i-1,j-1) and check(i-2,j-2)):
                print('Yes')
                break
    else:
        continue
    break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))
t = list(map(int, input().split()))
u = list(map(int, input().split()))

bingo = [s, t, u]

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

for i in range(3):
    for j in range(3):
        if bingo[i][j] in numbers:
            bingo[i][j] = 0

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

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

for i in range(3):
    if bingo[0][i] == 0 and bingo[1][i] == 0 and bingo[2][i] == 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)]

for num in b:
    for i in range(len(a)):
        for j in range(len(a[i])):
            if a[i][j] == num:
                a[i][j] = 'O'
                
if (a[0][0] == a[0][1] == a[0][2]) or (a[1][0] == a[1][1] == a[1][2]) or (a[2][0] == a[2][1] == a[2][2])\
or (a[0][0] == a[1][1] == a[2][2])\
or (a[0][0] == a[1][0] == a[2][0]) or (a[0][1] == a[1][1] == a[2][1]) or (a[0][2] == a[1][2] == a[2][2]):
    print('Yes')
else:
    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 or A[2] + A[4] + A[6] == 0:
  BINGO = 'Yes'
print(BINGO)