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:
# d = [[0]*3] * 3

# a = [[i for i in map(int, input().split())] for j in range(3)]
# n = int(input())

a = [[66, 85, 92], [56, 37, 86], [7, 52, 23]]
n = 9
B = [30, 85, 52, 48,89, 92, 26, 5, 67]

d = [[0] * 3 for i in range(3)]
for i  in range(n):
    # b = int(input())
    b = B[i]
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                d[j][k] = 1
# if ans[0][0] + ans[0][1] + ans[0][2] == 3 or ans[1][0] + ans[1][1] + ans[1][2] == 3 or ans[2][0] + ans[2][1] + ans[2][2] == 3 or ans[0][0] + ans[1][0] + ans[2][0] == 3 or ans[0][1] + ans[1][1] + ans[2][1] == 3 or ans[0][2] + ans[1][2] + ans[2][2] == 3 or ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3:
flag = False
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[i][j]
    if cnt == 3:
        flag = True

for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[j][i]
    if cnt == 3:
        flag = True

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

cnt = 0
for i in range(3):
    cnt += d[i][2-i]
    if cnt == 3:
        flag = True
print("Yes") if flag == True else print('No')

Submission status: Wrong Answer

Solution code:
f=lambda a:any(all(b)for b in a)or all(a[i][i]for i in(0,1,2))   
a=eval('list(map(int,input().split())),'*3)
exec('b=int(input());a=[[u*(u!=b)for u in t]for t in a];'*int(input()))
a=[[not u for u in t]for t in a]
r=0
exec('r|=f(a)|f(a[::-1]);a=[t[::-1]for t in a];'*2)
print('NYoe s'[r::2])

Submission status: Wrong Answer

Solution code:
a = [[i for i in map(int, input().split())] for j in range(3)]
n = int(input())
d = [[0]*3] * 3
for i  in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                d[j][k] = 1
# if ans[0][0] + ans[0][1] + ans[0][2] == 3 or ans[1][0] + ans[1][1] + ans[1][2] == 3 or ans[2][0] + ans[2][1] + ans[2][2] == 3 or ans[0][0] + ans[1][0] + ans[2][0] == 3 or ans[0][1] + ans[1][1] + ans[2][1] == 3 or ans[0][2] + ans[1][2] + ans[2][2] == 3 or ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3:
flag = False

for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[i][j]
    if cnt == 3:
        flag = True

for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[j][i]
    if cnt == 3:
        flag = True

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

cnt = 0
for i in range(3):
    cnt += d[i][2-i]
    if cnt == 3:
        flag = True
print("Yes") if flag == True else print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
A = []
for i in range(3):
    a = list(map(int, input().split()))
    A.append(a[:])
N = int(input())
F = [[False for _ in range(3)] for _ in range(3)]
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                F[j][k] = True
flag = False
for i in range(3):
    # if F[i][0] == F[i][1] == F[i][2] == True:
    if sum(F[i]) == 3:
        flag = True
for i in range(3):
    if F[0][i] == F[1][i] == F[i][2] == True:
        flag = True
if F[0][0] == F[1][1] == F[2][2] == True or F[2][0] == F[1][1] == F[0][2] == True:
    flag = True
print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
A = []
for i in range(3):
    a = list(map(int, input().split()))
    A.append(a[:])
N = int(input())
F = [[False for _ in range(3)] for _ in range(3)]
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                F[j][k] = True
flag = False
for i in range(3):
    if F[i][0] == F[i][1] == F[i][2] == True:
        flag = True
for i in range(3):
    if F[0][i] == F[1][i] == F[i][2] == True:
        flag = True
if F[0][0] == F[1][1] == F[2][2] == True or F[2][0] == F[1][1] == F[0][2] == True:
    flag = True
print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
lin = []
for i in range(3):
    for j in range(3):
        lin.append(li[i][j])
n = int(stdin.readline().rstrip())
lis = [int(stdin.readline().rstrip()) for _ in range(n)]
liv = []
for i in lin:
    if i in lis:
        liv.append(0)
    else:
        liv.append(1)
if liv[0:3] == [0,0,0] or liv[3:6] == [0,0,0] or liv[6:9] == [0,0,0]:
    print("Yes")
    exit()
for i in range(3):
    if liv[3*i] == 0 and liv[3*i+1] == 0 and liv[3*i+2] == 0:
        print("Yes")
        exit()
if liv[0] == 0 and liv[4] == 0 and liv[8] == 0:
    print("Yes")
    exit()
if liv[2] == 0 and liv[4] == 0 and liv[6] == 0:
    print("Yes")
    exit()
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()]
n=int(input())
b=set()
for i in range(n):
  b.add(int(input()))
def bingo():
  f=True
  for i in range(3):
    if not a1[i] in b:
      f=False
      break
  if f:
    return f
  f=True
  for i in range(3):
    if not a2[i] in b:
      f=False
      break
  if f:
    return f
  f=True
  for i in range(3):
    if not a3[i] in b:
      f=False
      break
  if f:
    return f
  for i in range(3):
    if a1[i] in b and a2[i] in b and a3[i] in b:
      return True
  if a1[0] in b and a2[1] in b and a3[2] in b:
    return True
  if a3[0] in b and a2[1] in b and a1[2] in b:
    return True
  return False
print('Yes') if bingo() else 'No'

Submission status: Wrong Answer

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

num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
a1, a2, a3, a4 = 0, 0, 0, 0
for j in range(3):
  a1, a2 = 0, 0
  for i in range(3):
    if(a[i][j] != 0):
      a1 = -1
    if(a[j][i] != 0):
      a2 = -1
    if(a1 == -1 and a2 == -1 and a3 == -1 and a4 == -1):
      print('No')
      exit()
  if(a[j][j] != 0):
    a3 = -1
  if(a[2-j][2-j] != 0):
    a4 = -1
if(a1 == -1 and a2 == -1 and a3 == -1 and a4 == -1):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
a1, a2, a3, a4 = 0, 0, 0, 0
for j in range(3):
  a1, a2 = 0, 0
  for i in range(3):
    if(a[i][j] != 0):
      a1 = -1
    if(a[j][i] != 0):
      a2 = -1
    if(a1 == -1 and a2 == -1 and a3 == -1 and a4 == -1):
      print('No')
      exit()
  if(a[j][j] != 0):
    a3 = -1
  if(a[2-j][2-j] != 0):
    a4 = -1
if(a3 == -1 and a4 == -1):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
a1, a2, a3 = 0, 0, 0
for j in range(3):
  a1, a2 = 0, 0
  for i in range(3):
    if(a[i][j] != 0):
      a1 = -1
    if(a[j][i] != 0):
      a2 = -1
    if(a1 == -1 and a2 == -1 and a3 == -1):
      print('No')
      exit()
  if(a[j][j] != 0):
    a3 = -1
if(a3 == -1):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np


card = np.array([list(map(int, input().split())) for _ in range(3)], dtype=np.int64)
n = int(input())
for _ in range(n):
    num = int(input())
    card[card == num] = 0
card = card == 0


def check_vertical(card):
    return np.all(card, axis=0).sum() == 3


def check_horizon(card):
    return np.all(card, axis=1).sum() == 3


def check_diagonal(card):
    check1 = np.diag(card).sum()
    check2 = np.diag(np.fliplr(card)).sum()
    return check1 == 3 or check2 == 3


if check_vertical(card) or check_horizon(card) or check_diagonal(card):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

 
num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
a1, a2, a3 = 0, 0, 0
for i in range(3):
    if(a[i][0] == 0 and a1 == 0):
      a1 = 0
    else:
      a1 = -1
    if(a[0][i] == 0 and a2 == 0):
      a2 = 0
    else:
      a2 = -1
    if(a[i][i] == 0 and a3 == 0):
      a3 = 0
    else:
      a3 = -1
    if(a1 != 0 and a2 != 0 and a3 != 0):
      print('No')
      exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
print('Yes')

Submission status: Wrong Answer

Solution code:
N = 3
S = [list(map(int, input().split())) for _ in range(N)]
n_guess = int(input())
guesses = set([int(input()) for _ in range(n_guess)])
dic = {}
for r in range(N):
  for c in range(N):
    dic[S[r][c]]=(r,c)

for g in guesses:
  if g in dic:
    (r, c) = dic[g]
    S[r][c] = -1
# print(S)
if all([S[i][0]==-1 for i in range(N)]) or \
   all([S[0][i]==-1 for i in range(N)]) or \
   all([S[i][N-i-1]==-1 for i in range(N)]) or \
   all([S[i][i]==-1 for i in range(N)]):
   	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
N = 3
S = [list(map(int, input().split())) for _ in range(N)]
n_guess = int(input())
guesses = set([int(input()) for _ in range(n_guess)])
dic = {}
for r in range(N):
  for c in range(N):
    dic[S[r][c]]=(r,c)

for g in guesses:
  if g in dic:
    (r, c) = dic[g]
    S[r][c] = -1
print(S)
if all([S[i][0]==-1 for i in range(N)]) or \
   all([S[0][i]==-1 for i in range(N)]) or \
   all([S[i][N-i-1]==-1 for i in range(N)]) or \
   all([S[i][i]==-1 for i in range(N)]):
   	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
list1 = input().split(" ")
list2 = input().split(" ")
list3 = input().split(" ")
count = int(input())
correct = ['o','o','o']
answer = "No"
for i in range(count):
	num = input()
	list1 = ['o' if num in s else s for s in list1]
	list2 = ['o' if num in s else s for s in list2]
	list3 = ['o' if num in s else s for s in list3]
	vlist1 = [list1[0],list2[0],list3[0]]
	vlist2 = [list1[1],list2[1],list3[1]]
	vlist3 = [list1[2],list2[2],list3[2]]
	xlist1 = [list1[0],list2[1],list3[2]]
	xlist2 = [list1[2],list2[1],list3[0]]
	if list1 == correct:
		answer = "Yes"
		break
	elif list2 == correct:
		answer = "Yes"
		break
	elif list3 == correct:
		answer = "Yes"
		break
	elif vlist1 == correct:
		answer = "Yes"
		break
	elif vlist2 == correct:
		answer = "Yes"
		break
	elif vlist3 == correct:
		answer = "Yes"
		break
	elif xlist1 == correct:
		answer = "Yes"
		break
	elif xlist2 == correct:
		answer = "Yes"
		break    
print(answer)

Submission status: Wrong Answer

Solution code:
list1 = input().split(" ")
list2 = input().split(" ")
list3 = input().split(" ")
count = int(input())
vlist1 = [list1[0],list2[0],list3[0]]
vlist2 = [list1[1],list2[1],list3[1]]
vlist3 = [list1[2],list2[2],list3[2]]
xlist1 = [list1[0],list2[1],list3[2]]
xlist2 = [list1[2],list2[1],list3[0]]
correct = ['o','o','o']
answer = "No"

for i in range(count):
	num = input()
	list1 = ['o' if num in s else s for s in list1]
	list2 = ['o' if num in s else s for s in list2]
	list3 = ['o' if num in s else s for s in list3]
	vlist1 = [list1[0],list2[0],list3[0]]
	vlist2 = [list1[1],list2[1],list3[1]]
	vlist3 = [list1[2],list2[2],list3[2]]
	xlist1 = [list1[0],list2[1],list3[2]]
	xlist2 = [list1[2],list2[1],list3[0]]
	if list1 == correct:
		answer = "Yes"
		break
	elif list2 == correct:
		answer = "Yes"
		break
	elif list3 == correct:
		answer = "Yes"
		break
	elif vlist1 == correct:
		answer = "Yes"
		break
	elif vlist2 == correct:
		answer = "Yes"
		break
	elif vlist3 == correct:
		answer = "Yes"
		break
	elif xlist1 == correct:
		answer = "Yes"
		break
	elif xlist2 == correct:
		answer = "Yes"
		break
      

    
print(answer)

Submission status: Wrong Answer

Solution code:
list1 = input().split(" ")
list2 = input().split(" ")
list3 = input().split(" ")
count = int(input())
vlist1 = [list1[0],list2[0],list3[0]]
vlist2 = [list1[1],list2[1],list3[1]]
vlist3 = [list1[2],list2[2],list3[2]]
xlist1 = [list1[0],list2[1],list3[2]]
xlist2 = [list1[2],list2[1],list3[0]]
correct = ['o','o','o']
answer = "no"

for i in range(count):
	num = input()
	list1 = ['o' if num in s else s for s in list1]
	list2 = ['o' if num in s else s for s in list2]
	list3 = ['o' if num in s else s for s in list3]
	vlist1 = [list1[0],list2[0],list3[0]]
	vlist2 = [list1[1],list2[1],list3[1]]
	vlist3 = [list1[2],list2[2],list3[2]]
	xlist1 = [list1[0],list2[1],list3[2]]
	xlist2 = [list1[2],list2[1],list3[0]]
	if list1 == correct:
		answer = "yes"
		break
	elif list2 == correct:
		answer = "yes"
		break
	elif list3 == correct:
		answer = "yes"
		break
	elif vlist1 == correct:
		answer = "yes"
		break
	elif vlist2 == correct:
		answer = "yes"
		break
	elif vlist3 == correct:
		answer = "yes"
		break
	elif xlist1 == correct:
		answer = "yes"
		break
	elif xlist2 == correct:
		answer = "yes"
		break
print(answer)

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
d = [[0]*3]*3
for  _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3): 
      if A[i][j] == b:
        d[i][j] = 1
 
ans = "No"
 
for i in range(3):
  if sum(d[i]) == 3:
    ans = "Yes"
    break
  if sum([D[i] for D in d]) == 3:
    ans = "Yes"
    break
if sum([d[i][i] for i in range(3)]) == 3:
  ans = "Yes"
 
if sum([d[i][2 - i] for i in range(3)]) == 3:
  ans = "Yes"
  
print(ans)

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())
num =[]
for j in range(n):
    num.append(int(input()))
if (a and d and g )in num:
    print('Yes')
elif (b and e and h) in num:
    print('Yes')
elif (c and f and i) in num:
    print('Yes')
elif (a and b and c) in num:
    print('Yes')
elif (g and h and i) in num:
    print('Yes')
elif (a and e and i) in num:
    print('Yes')
elif (c and e and g) in num:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    a = input().split()
    a = [int(x) for x in a]
    A.append(a)
N = int(input())

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0
T = 'No'
for i in range(3):
    if sum(A[:][i]) == 0 or sum(A[i][:]) == 0:
        T = 'Yes'
if A[0][0]+A[1][1]+A[2][2] == 0 or A[0][2]+A[1][1]+A[2][0] == 0:
    T = 'Yes'
print(T)

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    a = input().split()
    a = [int(x) for x in a]
    A.append(a)
N = int(input())
C = [[0 for _ in range(3)] for _ in range(3)]

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:    C[i][j] = 1
T = 'No'
for i in range(3):
    if sum(C[:][i]) == 3 or sum(C[i][:]) == 3:
        T = 'Yes'
if C[0][0]+C[1][1]+C[2][2] == 3 or C[0][2]+C[1][1]+C[2][0] == 3:
    T = 'Yes'
print(T)

Submission status: Wrong Answer

Solution code:
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[False]*3]*3
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                card[i][j] = True
    ans = "No"
    for i in range(3): #横に見てる
        if card[i][0] and card[i][1] and card[i][2]:
            ans = "Yes"
    for i in range(3): # 縦に見てる
        if card[0][i] and card[1][i] and card[2][i]:
            ans = "Yes"
    if card[0][0] and card[1][1] and card[2][2]:
        ans = "Yes"
    if card[0][2] and card[1][1] and card[2][0]:
        ans = "Yes"
    print(ans)

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []
 
for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
          total.append(k * 3 + j)
          
if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and 7 and 8) in total) or ((0 and 3 and 6) in total) or ((1 and 4 and 7) in total) or ((2 and 5 and 8) in total) or ((0 and 4 and 8) in total) or ((2 and 4 and 6) in total):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[False]*3]*3
    for i in range(3):
        for j in range(3):
            for k in range(n):
                if a[i][j] == b[k]:
                    card[i][j] = True
    ans = "No"
    for i in range(3): #横に見てる
        if card[i][0] and card[i][1] and card[i][2]:
            ans = "Yes"
    for i in range(3): # 縦に見てる
        if card[0][i] and card[1][i] and card[2][i]:
            ans = "Yes"
    if card[0][0] and card[1][1] and card[2][2]:
        ans = "Yes"
    if card[0][2] and card[1][1] and card[2][0]:
        ans = "Yes"
    print(ans)

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []
 
for i in range(n):
  s = 0
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        if k >= 1: 
          total.append(s + j)
        else:
          total.append(k + j)
    s = s + 3
if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and 7 and 8) in total) or ((0 and 3 and 6) in total) or ((1 and 4 and 7) in total) or ((2 and 5 and 8) in total) or ((0 and 4 and 8) in total) or ((2 and 4 and 6) in total):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
SIZE = 3
A = [[int(i) for i in input().split()] for j in range(SIZE)]
N = int(input())
B = [int(input()) for j in range(N)]


def rotate_counterclockwise(matrix):
    """2次元リストを反時計回りに回転"""
    return list(map(list, zip(*matrix)))[::-1]


for b in B:
    for row in range(SIZE):
        for col in range(SIZE):
            if A[row][col] == b:
                A[row][col] = 0

ans = 'No'
for _ in range(2):
    # 行と対角成分のそれぞれについて、和が 0 になったらビンゴとなる
    for row in range(SIZE):
        if sum(A[row]) == 0:
            ans = 'Yes'
    if sum(A[k][k] for k in range(SIZE)):
        ans = 'Yes'
    # カードを回転させることで、同じ処理を使い回す
    A = rotate_counterclockwise(A)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[0]*3]*3
    for i in range(3):
        for j in range(3):
            card[i][j]  == False
            for k in range(n):
                if a[i][j] == b[k]:
                    card[i][j] = True
    ans = "No"
    for i in range(3): #横に見てる
        if card[i][0] and card[i][1] and card[i][2]:
            ans = "Yes"
    for i in range(3): # 縦に見てる
        if card[0][i] and card[1][i] and card[2][i]:
            ans = "Yes"
    if card[0][0] and card[1][1] and card[2][2]:
        ans = "Yes"
    if card[0][2] and card[1][1] and card[2][0]:
        ans = "Yes"
    print(ans)

    
if __name__ == "__main__":
    main()

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()))

number_nex = list(set(number))
print(number_nex)

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

bingo_a = 'No'
for t in range(3):
    t_a = 0
    for y in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                t_a += 1
    if(t_a == 3):
        bingo_a = 'Yes'

for y in range(3):
    y_a = 0
    for t in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                y_a += 1
    if(y_a == 3):
        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:
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()))

number_nex = list(set(number))

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

bingo_a = 'No'
for t in range(3):
    t_a = 0
    for y in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                t_a += 1
    if(t_a == 3):
        bingo_a = 'Yes'

for y in range(3):
    y_a = 0
    for t in range(3):
        for r in range(len(result)):
            if(result[r][0] == t and result[r][1] == y):
                y_a += 1
    if(y_a == 3):
        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:
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

i = 0 
j = 0
if bingo[i][j] == -1 and bingo[i][j+1] == -1 and bingo[i][j+2] == -1:
                cnt = 1
if bingo[i][j] == -1 and bingo[i+1][j] == -1 and bingo[i+2][j] == -1:
                cnt = 1

if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
                cnt = 1
if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1:
                cnt = 1
if cnt == 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

i = 0 
j = 0
if bingo[i][j] == -1 and bingo[i][j+1] == -1 and bingo[i][j+2] == -1:
                cnt -1
if bingo[i][j] == -1 and bingo[i+1][j] == -1 and bingo[i+2][j] == -1:
                cnt = 1

if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
                cnt = 1
if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1:
                cnt = 1
if cnt == 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

i = 0 
j = 0
if bingo[i][j] == -1 and bingo[i][j+1] == -1 and bingo[i][j+2] == -1:
                cnt -1
if bingo[i][j] == -1 and bingo[i+1][j] == -1 and bingo[i+2][j] == -1:
                cnt = 1

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

Submission status: Wrong Answer

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

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

if i == 0 and j == 0:
    if bingo[i][j] == -1 and bingo[i][j+1] == -1 and bingo[i][j+2] == -1:
                cnt -1
    if bingo[i][j] == -1 and bingo[i+1][j] == -1 and bingo[i+2][j] == -1:
                cnt = 1

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

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    a = input().split()
    a = [int(x) for x in a]
    A.append(a)
N = int(input())
C = [[0 for _ in range(3)] for _ in range(3)]
 
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                C[i][j] = 1
T = "No"
for i in range(3):
    if sum(C[:][i]) == 3:
        T = 'Yes'
    elif sum(C[i][:]) == 3:
        T = 'Yes'
if C[1][1]+C[2][2]+C[0][0] == 3:
    T = 'Yes'
elif C[0][2]+C[1][1]+C[2][0] == 3:
    T = 'Yes'
print(T)

Submission status: Wrong Answer

Solution code:
import numpy as np
A = []
for i in range(3):
    a = []
    a = input().split()
    A.append([int(x) for x in a])
N = int(input())
C = []
for _ in range(3):
    C.append(np.zeros(3))
 
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b: C[i][j] = 1
 
for i in range(3):
    if sum(C[:][i]) == 3:
        print('Yes')
        exit()
    elif sum(C[i][:]) == 3:
        print('Yes')
        exit()
if C[1][1]+C[2][2]+C[0][0] == 3:
    print('Yes')
elif C[0][2]+C[1][1]+C[2][0] == 3:
    print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
li_a = list(map(int,input().split()))
li_b = list(map(int,input().split()))
li_c = list(map(int,input().split()))
n = int(input())
li_num=[int(input()) for i in range(n)]
 
li_card = [li_a, li_b, li_c]
 
ans = False
 
#print(li_card)
#print(li_b)
#print(li_c)
#print(n)
#print(li_num)
 
for m in li_num:
    for i in range(3):
        for j in range(3):
          if li_card[i][j] == m:
              li_card[i][j] = 0
 
#print(li_card)
 
for i in range(3):
    if li_card[i][0] == li_card[i][1] == li_card[i][2]:
        ans = True
        break
    elif li_card[i][0] == li_card[i][1] == li_card[i][2]:
        ans = True
        break
 
if not ans:
  if li_card[0][0] == li_card[1][1] == li_card[2][2]:
      ans = True
  elif li_card[0][2] == li_card[1][1] == li_card[2][0]:
      ans = True
 
if ans:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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