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 i in range(3)]
for i in range(int(input())):
  i = int(input())
  bo = True
  while(bo):
    for k,a_1 in enumerate(a[0]):
      if a_1 == i:
        a[0][k] = None
        bo = False
    for k,a_2 in enumerate(a[1]):
      if a_2 == i:
        a[1][k] = None
        bo = False
    for k,a_3 in enumerate(a[2]):
      if a_3 == i:
        a[2][k] = None
        bo = False
    bo = False
s = "No"
while(s == "No"):
  if (a[0][0] == a[1][1]) and (a[1][1] == a[2][2]):
    s = "Yes"
  if (a[2][2] == a[1][1]) and (a[1][1] == a[0][0]):
    s = "Yes"
  for l in a:
    if len(set(l)) == 1:
      s = "Yes"
  for i in range(3):
    if len(set([a[0][i], a[1][i], a[2][i]])) == 1:
      s = "Yes"
  break
print(s)

Submission status: Wrong Answer

Solution code:
a0=list(map(int, input().split()))
a1=list(map(int, input().split()))
a2=list(map(int, input().split()))
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))
ans=[]
for i in b:
    if (i in a0) == True:
        ans.append(a0.index(i))
    if (i in a1) == True:
        ans.append((a1.index(i))+3)
    if (i in a2) == True:
        ans.append((a2.index(i))+6)
if (0 in ans) == True:
    if (1 in ans) == True:
        if (2 in ans) == True:
            print("Yes")
    elif (3 in ans) == True:
        if (6 in ans) == True:
            print("Yes")
    elif (4 in ans) == True:
        if (8 in ans) == True:
            print("Yes")
elif (1 in ans)==True:
    if  (4 in ans)==True:
        if  (7 in ans)==True:
            print("Yes")
elif (2 in ans)==True:
    if  (5 in ans)==True:
        if  (8 in ans)==True:
            print("Yes")
    elif (4 in ans)==True:
        if (6 in ans)==True:
            print("Yes")
elif (3 in ans)==True:
    if  (4 in ans)==True:
        if  (5 in ans)==True:
            print("Yes")
elif (6 in ans)==True:
    if  (7 in ans)==True:
        if  (8 in ans)==True:
            print("Yes")
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())
b=[]
for i in range(n):
    b.append(int(input()))

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

Submission status: Wrong Answer

Solution code:
import numpy as np
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
a = list(np.array(a).flatten())
N = int(input())
index = []
for _ in range(N):
    b_i = int(input())
    if b_i in a:
        indexes = [i for i, x in enumerate(a) if x == b_i]
        for i in indexes:
            index.append(i)
print(index)
for i in sorted(index):
    if i + 1 in index and i + 2 in index:
        print("Yes")
        exit()
    if i + 2 in index and i + 4 in index:
        print("Yes")
        exit()
    if i + 3 in index and i + 6 in index:
        print("Yes")
        exit()
    if i + 4 in index and i + 8 in index:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
A = []
B = set()
ans = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
for i in range(N):
    B.add(int(input()))

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

#ゴミコードだなぁ……

if ans[0][0] + ans[0][1] + ans[0][2] == 3:
    print('Yes')
elif ans[0][0] + ans[1][0] + ans[2][0] == 3:
    print('Yes')
elif ans[0][0] + ans[1][1] + ans[2][2] == 3:
    print('Yes')
elif ans[1][0] + ans[1][1] + ans[1][2] == 3:
    print('Yes')
elif ans[2][0] + ans[2][1] + ans[2][2] == 3:
    print('Yes')
elif ans[0][1] + ans[1][1] + ans[2][1] == 3:
    print('Yes')
elif ans[0][2] + ans[1][2] + ans[1][2] == 3:
    print('Yes')
elif ans[0][2] + ans[1][1] + ans[2][0] == 3:
    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-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(i-2 >= 0 and j+1 < 3 == 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:
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
a3 = [int(i) for i in input().split()]
a = [a1, a2, a3]
b = [[0] * 3] * 3
n = int(input())
for i in range(n):
    x = int(input())
    for i1 in range(3):
        for i2 in range(3):
            if a[i1][i2] == 1:
                continue

            if x == a[i1][i2]:
                b[i1][i2] = 1
                break


for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += b[i][j]
    if cnt == 3:
        print("Yes")
        exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += [j][i]
    if cnt == 3:
        print("Yes")
        exit()

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


print("No")

Submission status: Wrong Answer

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

ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    col = 0
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
      	col += bingo[j][k]
    if col == -3:
      ans = "Yes"
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
      
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
a = [ list(map(int,input().split(" "))) for i in range(3)]
N=int(input())
c=0
for i in range(N):
  b=int(input())
  for j in range(3):
    c=0
    for z in range(3):
      if a[j][z]-b==0:
        c+=1
        a[j][z]=0
        if c==3:
          print('Yes')
          sys.exit()
if a[0][0]+a[1][1]+a[2][2]==0 or a[2][0]+a[1][1]+a[0][2]==0:
    print('Yes')
    sys.exit()
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)]
z =map(int,z)
if a and d and g in z or b and e and h in z or c and f and i in z or a and b and c in z or c and e and f in z or g and h and i in z or a and e and i in z or g and e and c in z:
  print('Yes')
else :
  print('No')

Submission status: Wrong Answer

Solution code:
def resolve():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(len(a)):
            if a[j] == b:
                a[j] = -1
    x1 = a[0:3].count(-1)
    x2 = a[3:6].count(-1)
    x3 = a[6:9].count(-1)
    y1 = a[0:7:3].count(-1)
    y2 = a[1:8:3].count(-1)
    y3 = a[2:9:3].count(-1)
    nn = a[0:9:4].count(-1)

    if x1 == 3 or x2 == 3 or x3 == 3 or y1 == 3 or y2 == 3 or y3 == 3 or nn == 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
a = []
check = []
for i in range(3):
    a.append([int(j) for j in input().split()])

d1 = [a[0][0],a[1][1], a[2][2]]
d2 = [a[0][2],a[1][1], a[2][0]]
col1 = [a[0][0],a[0][1], a[0][2]]
col2 = [a[1][0],a[1][1], a[1][2]]
col3 = [a[2][0],a[2][1], a[2][2]]

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


if any(elem in check for elem in d1):
    print("Yes")
elif any(elem in check for elem in d2):
    print("Yes")
elif any(elem in check for elem in col1):
    print("Yes")
elif any(elem in check for elem in col2):
    print("Yes")
elif any(elem in check for elem in col3):
    print("Yes")
elif any(elem in check for elem in a[0]):
    print("Yes")
elif any(elem in check for elem in a[1]):
    print("Yes")
elif any(elem in check for elem in a[2]):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
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")
        sys.exit()
  ANS = 0

ANS = 0
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
    sys.exit()
  else:
    print("No")
    sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = []
for i in range(3):
  tmp = input()
  a.append(list(map(int, tmp.split())))

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

# print(a)
# print(b)

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

def check(a):
    #　たてビンゴ
    for i in range(3):
        if (a[i][0] == 0 & a[i][1] == 0 & a[i][2] == 0):
            print('Yes')
            exit()
    # 横ビンゴ
        if a[i] == [0, 0, 0]:
            print('Yes')
            exit()
    # 斜めビンゴ
    if a[0][0] == 0 & a[1][1] == 0 & a[2][2] == 0:
            print('Yes')
            exit()
    if a[0][2] == 0 & a[1][1] == 0 & a[2][0] == 0:
            print('Yes')
            exit()
    print('No')

check(a)

Submission status: Wrong Answer

Solution code:
A = [input().split() for l in range(3)]
N = int(input())
b = [input() for i in range(N)]
def bingo(A,b):
    c = [[0,0,0],[0,0,0],[0,0,0]]
    for i in range(0,len(b)):
        for j in range(0,3):
            for k in range(0,3):
                if A[j][k] == b[i]:
                    c[j][k] = 1
    if c[0] == [1,1,1] or c[1] == [1,1,1] or c[2] == [1,1,1]:
        return 'Yes'
    elif c[0][0] == c[1][0] == c[2][0] == 1 or c[0][1] == c[1][1] == c[2][1] == 1 or c[0][2] == c[1][2] == c[2][2] == 1:
        return 'Yes'
    elif c[0][0] == c[1][1] == c[2][2] == 1 or c[0][2] == c[1][1] == c[2][0] == i:
        return 'Yes'
    else:
        return 'No'
print(bingo(A,b))

Submission status: Wrong Answer

Solution code:
input1 = list(map(int, (input().split())))
input2 = list(map(int, (input().split())))
input3 = list(map(int, (input().split())))

a = input1 + input2 + input3

n = int(input())

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

for s in b:
    for i in range(9):
        if a[i] == s:
            a[i] = 0

for i in range(3):
    if(a[i] == a[i+3] and a[i] == a[i+6]):
        print("YES")
        exit(0)

for i in range(0, 3, 3):
    if(a[i] == a[i+1] and a[i] == a[i+2]):
        print("YES")
        exit(0)

if(a[0] == a[4] and a[i] == a[8]):
    print("YES")
    exit(0)

if(a[2] == a[4] and a[i] == a[6]):
    print("YES")
    exit(0)

print("NO")

Submission status: Wrong Answer

Solution code:
import numpy as np

def isin(v, cls):
    ind = np.zeros(v.shape[0], dtype=bool)
    v_cls = np.argmax(v, axis=1)
    for c in cls:
        ind |= (v_cls == c)
    return v[ind]

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

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
T = isin(A,b)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).all()
ans[1]=T.all(axis=1).all()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
if any(ans):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def resolve():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(len(a)):
            if a[j] == b:
                a[j] = -1
    x1 = a[0:3].count(-1)
    x2 = a[3:6].count(-1)
    x3 = a[6:9].count(-1)
    y1 = a[0:7:3].count(-1)
    y2 = a[1:8:3].count(-1)
    y3 = a[2:9:3].count(-1)
    nn = a[0:9:4].count(-1)

    if x1 == 3 or x2 == 3 or x3 == 3 or y1 == 3 or y2 == 3 or y3 == 3 or nn == 3:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    col = 0
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
      	col += bingo[j][k]
    if col == -3:
      ans = "Yes"
    if sum(bingo[k]) == -3:
  	  ans = "Yes"
    print(col)
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
b = []
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
b.append(a1)
b.append(a2)
b.append(a3)
n = int(input())
c = [int(input()) for i in range(n)]
a = []
d = [[0 for i in range(3)] for j in range(3)]
for nn, i in enumerate(c):
	for j in range(3):
		for k in range(3):
			if b[j][k] == i:
				d[j][k] = 1
	if nn == n-1:
		if d[0][0] == 1 and d[1][1] == 1 and d[2][2] == 1:
			print ("Yes")
			exit()
		if d[0][2] == 1 and d[1][1] == 1 and d[2][0] == 1:
			print ("Yes")
			exit()
		if d[0][0] == 1 and d[0][1] == 1 and d[0][2] == 1:
			print ("Yes")
			exit()
		if d[1][0] == 1 and d[1][1] == 1 and d[1][2] == 1:
			print ("Yes")
			exit()
		if d[2][0] == 1 and d[2][1] == 1 and d[2][2] == 1:
			print ("Yes")
			exit()
		if d[0][0] == 1 and d[0][1] == 1 and d[0][2] == 1:
			print ("Yes")
			exit()
		if d[1][0] == 1 and d[1][1] == 1 and d[1][2] == 1:
			print ("Yes")
			exit()
		if d[2][0] == 1 and d[2][1] == 1 and d[2][2] == 1:
			print ("Yes")
			exit()
print ("No")

Submission status: Wrong Answer

Solution code:
bingo = [ input().split() for j in range(3)]
N = int(input())
b = []
for n in range(N):
	b.append(input())
count = 0
total = 0
p = 'No'
for x in range(N):
	for i in range(3):
		for j in range(3):
			count = count + 1
			if bingo[i][j] == b[x]:
				total = total + count
	count = 0
	if total == 6 or total == 12 or total == 15 or total == 18 or total == 24 or total == 33 or total == 36 or total == 27 or total == 30:
		p = 'Yes'
		break
print(p)

Submission status: Wrong Answer

Solution code:
A_list_yoko1 = list(map(int, input().split()))
A_list_yoko2 = list(map(int, input().split()))
A_list_yoko3 = list(map(int, input().split()))
N = int(input())
B_list = []
for i in range(N):
    B_list.append(int(input()))

A_list_tate1 = []
A_list_tate2 = []
A_list_tate3 = []
A_list_naname1 = []
A_list_naname2 = []

A_list_tate1.append(A_list_yoko1[0])
A_list_tate1.append(A_list_yoko2[0])
A_list_tate1.append(A_list_yoko3[0])
A_list_tate2.append(A_list_yoko1[1])
A_list_tate2.append(A_list_yoko2[1])
A_list_tate2.append(A_list_yoko3[1])
A_list_tate3.append(A_list_yoko1[2])
A_list_tate3.append(A_list_yoko2[2])
A_list_tate3.append(A_list_yoko3[2])
A_list_naname1.append(A_list_yoko1[0])
A_list_naname1.append(A_list_yoko2[1])
A_list_naname1.append(A_list_yoko3[2])
A_list_naname2.append(A_list_yoko1[2])
A_list_naname2.append(A_list_yoko2[1])
A_list_naname2.append(A_list_yoko3[0])

A_list_yoko1_c = []
A_list_yoko2_c = []
A_list_yoko3_c = []
A_list_tate1_c = []
A_list_tate2_c = []
A_list_tate3_c = []
A_list_naname1_c = []
A_list_naname2_c = []
for i in B_list:
    if i in A_list_yoko1:
        A_list_yoko1_c.append(A_list_yoko1.index(i))
    if i in A_list_yoko2:
        A_list_yoko2_c.append(A_list_yoko2.index(i))
    if i in A_list_yoko3:
        A_list_yoko3_c.append(A_list_yoko3.index(i))
    if i in A_list_tate1:
        A_list_tate1_c.append(A_list_tate1.index(i))
    if i in A_list_tate2:
        A_list_tate2_c.append(A_list_tate2.index(i))
    if i in A_list_tate3:
        A_list_tate3_c.append(A_list_tate3.index(i))
    if i in A_list_naname1:
        A_list_naname1_c.append(A_list_naname1.index(i))
    if i in A_list_naname2:
        A_list_naname2_c.append(A_list_naname2.index(i))

if sum(A_list_naname1_c) == 3 or sum(A_list_naname2_c) == 3 or sum(A_list_tate1_c) == 3 or sum(A_list_tate2_c) == 3 or sum(A_list_tate3_c) == 3 or sum(A_list_yoko1_c) == 3 or sum(A_list_yoko2_c) == 3 or sum(A_list_yoko3_c) == 3:
    print("Yes")
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()))
result = 'No'

n = int(input())
for i in range(n):
	In = int(input())
    
	a1 = ['' if a1[j] == In else a1[j] for j in range(3)]
	a2 = ['' if a2[j] == In else a2[j] for j in range(3)]
	a3 = ['' if a3[j] == In else a3[j] for j in range(3)]
    
# tate
for i in range(2):
	if a1[i] == '' and a2[i] == '' and a3[i] == '':
		result = 'Yes'
		break
# yoko
if a1.count('') == 3:
		result = 'Yes'
if a2.count('') == 3:
		result = 'Yes'
if a3.count('') == 3:
		result = 'Yes'

# naname
if a1[0] == '' and a2[1] == '' and a3[2] == '':
		result = 'Yes'
    
if a1[2] == '' and a2[1] == '' and a3[0] == '':
		result = 'Yes'
print(result)

Submission status: Wrong Answer

Solution code:
a = input().split()
a += input().split()
a += input().split()
n = int(input())
b = set([(input()) for i in range(n)])

bingo = False
if set([a[0], a[1], a[2]]).issubset(b):
	bingo = True
if set([a[3], a[4], a[5]]).issubset(b):
	bingo = True
if set([a[6], a[7], a[8]]).issubset(b):
	bingo = True
if set([a[0], a[3], a[6]]).issubset(b):
	bingo = True
if set([a[1], a[4], a[7]]).issubset(b):
	bingo = True
if set([a[2], a[5], a[8]]).issubset(b):
	bingo = True
if set([a[0], a[4], a[8]]).issubset(b):
	bingo = True
if set([a[2], a[4], a[6]]).issubset(b):
	bingo = True
if bingo:
  print("Yes")
print("No")

Submission status: Wrong Answer

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

N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == b:
                bingo[j][k] = 0
flag = False
for i in range(3):
    tmp = 0
    for j in range(3):
        tmp += bingo[i][j]
    if tmp == 0:
        flag = True
for j in range(3):
    tmp = 0
    for i in range(3):
        tmp += bingo[i][j]
    if tmp == 0:
        flag = True
if bingo[0][0] + bingo[1][1] + bingo[2][2] == 0:
    flag = True
if bingo[0][2] + bingo[1][1] + bingo[2][2] == 0:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import itertools
import sys

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for i in range(N):
  n = int(input())
  num_list.append(n)
set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i}]
the_set = set(num_list) & set([a,b,c,d,e,f,g,h,i])
v = itertools.permutations(the_set,3)
for i in v:
  if i in set_list:
    print('Yes')
    sys.exit()
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

    for i in range(3):
        # row
        if False not in res[i]:
            print("Yes")
            return

        # col
        if False not in [res[i][0], res[i][1], res[i][2]]:
            print("Yes")
            return

    # cross
    # ->
    if False not in [res[0][0], res[1][1], res[2][2]]:
        print("Yes c")
        return

    # <-
    if False not in [res[0][2], res[1][1], res[2][0]]:
        print("Yes c")
        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:
import sys

input = sys.stdin.readline


def main():
    bingo = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    bn = [int(input()) for _ in range(N)]
    hit = [[0] * 3 for _ in range(3)]
    cnt = 0
    hitz = []
    hzb, hb = False, False
    for b in bn:
        for v, i in enumerate(bingo):
            for w, j in enumerate(i):
                if b == j:
                    if j in hit:
                        continue
                    hit[w][v] = 1
                    cnt += 1
    hitz = list(map(list, zip(*hit)))
    for i in hitz:
        if sum(i) == 3:
            hzb = True
            break
    for i in hit:
        if sum(i) == 3:
            hb = True
            break
    print(cnt)
    if cnt >= 3 and (
        hzb == True
        or hb == True
        or hit[0][0] == hit[1][1] == hit[2][2] == 1
        or hit[0][2] == hit[1][1] == hit[2][0] == 1
    ):
        print("Yes")

    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))
loopflag = False
result.sort()
print(result)
if N >= 3:
    for i in range(len(result)):
        for j in range(len(result)):
            for k in range(len(result)):
                if (i!=j and j!=k and k!=i):
                    if((result[i] % 3 == result[j] % 3 == result[k] % 3 ) or (result[i] // 3 == result[j] // 3 == result[k] // 3) or (result[i] == 0 and result[j] == 4 and result[k] ==8 ) or (result[i] == 2 and result[j]  == 4 and result[k] == 6 )):
                        loopflag = True
    if loopflag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# B
a = []
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    a.append(a1)
    a.append(a2)
    a.append(a3)
    
print(a)
    
n = int(input())
b = []
for i in range(n):
    bb = int(input())
    b.append(bb)
    
for i in range(n):
    while a.count(b[i]) > 0:
        a[a.index(b[i])] = 0
        
if a[0] == a[3] == a[6] == 0:
    print('Yes')
elif a[1] == a[4] == a[7] == 0:
    print('Yes')
elif a[2] == a[5] == a[8] == 0:
    print('Yes')
elif a[0] == a[1] == a[2] == 0:
    print('Yes')
elif a[3] == a[4] == a[5] == 0:
    print('Yes')
elif a[6] == a[7] == a[8] == 0:
    print('Yes')
elif a[0] == a[4] == a[8] == 0:
    print('Yes')
elif a[2] == a[4] == a[6] == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import math
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = []
a.append(a1)
a.append(a2)
a.append(a3)

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

bingo = [ [0 for _ in range(3)] for __ in range(3)]

for bt in b:
  for i, at in enumerate(a1):
    if at == bt:
      bingo[0][i] = 1
  for i, att in enumerate(a2):
    if att == bt:
      bingo[1][i] = 1
  for i, attt in enumerate(a3):
    if attt == bt:
      bingo[2][i] = 1

for l in range(3):
  if sum(bingo[l]) == 3:
    print("Yes")
    quit()
  if bingo[0][l] + bingo[1][l] +bingo[2][l] == 3:
    print("Yes")
    quit()
if bingo[0][0] + bingo[1][1] +bingo[2][2] == 3:
    print("Yes")
    quit()
if bingo[0][2] + bingo[1][l] +bingo[2][0] == 3:
    print("Yes")
    quit()

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)]
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)>=7:
  print('Yes')
elif len(l)<=2:
  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=1,1
    for i in range(len(l)-1):
      if l[i][0]==l[i+1][0]:
        count1+=1
      elif count1!=3:
        count1=1
      if l[i][1]==l[i+1][1]:
        count2+=1
      elif count2!=3:
        count2=1
    if count1==3 or count2==3:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
up = list(input().split())
mid = list(input().split())
down = list(input().split())

table = [up, mid, down]
# print(table)
nums = []
while True:
    try:
        nums.append(input())
    except EOFError:
        break
# print(nums)

for i in range(3):
  for j in range(3):
    if table[i][j] in nums:
      table[i][j] = 'T'

flag = False
# yoko check
for i in range(3):
  if table[i].count('T') == 3:
    print('Yes')
    flag = True

# tate check
if flag == False:
  if table[0][0]=='T' and table[0][1]=='T' and table[0][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[1][0]=='T' and table[1][1]=='T' and table[1][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[2][0]=='T' and table[2][1]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True

# naname check
if flag == False:
  if table[0][0]=='T' and table[1][1]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][2]=='T' and table[1][1]=='T' and table[2][0]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys
a = []
b = []
c = [[False for i in range(3)] for i in range(3)]
for i in range(3):
    a.append(list(map(int, input().split())))

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

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                c[j][k] = True
# 縦
for i in range(3):
    if c[i] == [True, True, True]:
        print("Yes")
        sys.exit(0)

for i in range(3):
    if [c[0][j], c[1][j], c[2][j]] == [True, True, True]:
        print("Yes")
        sys.exit(0)

if [c[0][0], c[1][1], c[2][2]] == [True, True, True] or [c[0][2], c[1][1], c[2][0]] == [True, True, True]:
    print("Yes")
    sys.exit(0)
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()))
A = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))
loopflag = False
result.sort()
if N >= 3:
    for i in range(len(result)):
        for j in range(len(result)):
            for k in range(len(result)):
                if (i==j or j==k or k==i):
                    break 
                if((result[i] % 3 == result[j] % 3 == result[k] % 3 ) or (result[i] // 3 == result[j] // 3 == result[k] // 3) or (result[i] == 0 and result[j] == 4 and result[k] ==8 ) or (result[i] == 2 and result[j]  == 4 and result[k] == 6 )):
                    loopflag = True
    if loopflag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = input().split()
a += input().split()
a += input().split()
n = int(input())
b = set([(input()) for i in range(n)])

bingo = False
if set([a[0], a[1], a[2]]).issubset(b):
	bingo = True
if set([a[3], a[4], a[5]]).issubset(b):
	bingo = True
if set([a[6], a[7], a[8]]).issubset(b):
	bingo = True
if set([a[0], a[3], a[6]]).issubset(b):
	bingo = True
if set([a[1], a[4], a[7]]).issubset(b):
	bingo = True
if set([a[2], a[5], a[8]]).issubset(b):
	bingo = True
if set([a[0], a[4], a[8]]).issubset(b):
	bingo = True
if set([a[2], a[4], a[6]]).issubset(b):
	bingo = True
print(bingo)

Submission status: Wrong Answer

Solution code:
a = [list(map(int,input().split())) for i in range(3)]
for i in range(int(input())):
  i = int(input())
  bo = True
  while(bo):
    for k,a_1 in enumerate(a[0]):
      if a_1 == i:
        a[0][k] = None
        bo = False
    for k,a_2 in enumerate(a[1]):
      if a_2 == i:
        a[1][k] = None
        bo = False
    for k,a_3 in enumerate(a[2]):
      if a_3 == i:
        a[2][k] = None
        bo = False
    bo = False
s = "No"
while(s == "No"):
  if (a[0][0] == a[1][1]) and (a[1][1] == a[2][2]):
    s = "Yes"
  if (a[2][2] == a[1][1]) and (a[1][1] == a[0][0]):
    s = "Yes"
  for l in a:
    if set(l) == 1:
      s = "Yes"
  for i in range(3):
    if set([a[0][i], a[1][i], a[2][i]]) == 1:
      s = "Yes"
  break
print(s)