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_lists = [map(int, input().split()) for _ in range(3)]
num_dict = {}
for n1, A_list in enumerate(A_lists):
    for n2, a in enumerate(A_list):
        num_dict[a] = (n1, n2)

N = int(input())
B_list = [int(input()) for _ in range(N)]
bing_ar = [[False, False, False] for _ in range(3)]

keys = num_dict.keys()
for b in B_list:
    if b in num_dict:
        n1, n2 = num_dict[b]
        bing_ar[n1][n2] = True

if ((sum(bing_ar[0]) == 3) or (sum(bing_ar[1]) == 3) or (sum(bing_ar[2]) == 3)) or \
    ((bing_ar[0][0] == True) and (bing_ar[0][1] == True) and (bing_ar[0][2] == True)) or \
    ((bing_ar[1][0] == True) and (bing_ar[1][1] == True) and (bing_ar[1][2] == True)) or \
    ((bing_ar[2][0] == True) and (bing_ar[2][1] == True) and (bing_ar[2][2] == True)) or \
    ((bing_ar[0][0] == True) and (bing_ar[1][1] == True) and (bing_ar[2][2] == True)) or \
    ((bing_ar[0][2] == True) and (bing_ar[1][1] == True) and (bing_ar[2][0] == True)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

a = inpll(3)
n = inp()
B = inplm(n)

tmp = np.zeros((3,3),dtype=np.int)

for b in B:
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                tmp[i][j] = 1

ans = 'No'
if np.any(np.all(tmp == 1,axis=0) == True) or np.any(np.all(tmp == 1,axis=1) == True) or (tmp[0][0] == 1 and tmp[1][1] == 1 and tmp[2][2] == 1):
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
# B - Bingo
import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))#mapオブジェクトにlistをつける

bingo = [A[0],A[1],A[2],[A[0][0],A[1][0],A[2][0]],[A[0][1],A[1][1],A[2][1]],[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][2],A[2][2]],[A[0][2],A[1][1],A[2][0]]]

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))#タプルをリストに直す
    
result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'
        print('yes',B_perm[j])

print(result)

Submission status: Wrong Answer

Solution code:
# B - Bingo
import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))#mapオブジェクトにlistをつける

bingo = [A[0],A[1],A[2],[A[0][0],A[1][0],A[2][0]],[A[1][0],A[1][1],A[1][2]],[A[2][0],A[2][1],A[2][2]],[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][2],A[2][2]],[A[0][2],A[1][1],A[2][0]]]

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))#タプルをリストに直す
    
result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'
        print('yes',B_perm[j])

print(result)

Submission status: Wrong Answer

Solution code:
# B - Bingo
import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))#mapオブジェクトにlistをつける

bingo = [A[0],A[1],A[2],[A[0][0],A[1][0],A[2][0]],[A[1][0],A[1][1],A[2][1]],[A[2][0],A[2][1],A[2][2]],[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))#タプルをリストに直す
    
result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'

print(result)

Submission status: Wrong Answer

Solution code:
# B - Bingo
import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))#mapオブジェクトにlistをつける

bingo = [A[0],A[1],A[2],[A[0][0],A[1][0],A[2][0]],[A[1][0],A[1][1],A[2][1]],[A[2][0],A[2][1],A[2][2]],[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))#タプルをリストに直す
print(B_perm)
    
result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'

print(result)

Submission status: Wrong Answer

Solution code:
# B - Bingo
import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))#mapオブジェクトにlistをつける

bingo = [[A[0],A[1],A[2]],[A[0][0],A[1][0],A[2][0]],[A[1][0],A[1][1],A[2][1]],[A[2][0],A[2][1],A[2][2]],[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))#タプルをリストに直す
    
result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'

print(result)

Submission status: Wrong Answer

Solution code:
# B - Bingo
import itertools
A = list()
for o in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
b = list(int(input()) for p in range(N))#mapオブジェクトにlistをつける

bingo = [[A[0],A[1],A[2]],[A[0][0],A[1][0],A[2][0]],[A[1][0],A[1][1],A[2][1]],[A[2][0],A[2][1],A[2][2]],[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]
print(bingo)

B_perm = []    
B = itertools.permutations(b,3)
for i in B:
    B_perm.append(list(i))#タプルをリストに直す
    
result = 'No'
for j in range(len(B_perm)):
    if B_perm[j] in bingo: 
        result = 'Yes'

print(result)

Submission status: Wrong Answer

Solution code:
def mapt(fn, *args):
    return list(map(fn, *args))
  

a = [mapt(int, input().split(" ")) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for d in b:
    for i in range(3):
        for j in range(3):
            if d == a[i][j]:
                a[i][j] = True; continue

checksum = [i for i in zip(*a)]
checksum2 = [[a[0][0], a[1][1], a[2][2]]]
result = a + checksum + checksum2
print("Yes" if any(a == b == c == True for a, b, c in result) else "No")

Submission status: Wrong Answer

Solution code:
from itertools import combinations


def mapt(fn, *args):
    return tuple(map(fn, *args))
  
a = [mapt(int, input().split(" ")) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
a.append((a[0][0], a[1][1], a[2][2]))

combinated = [sorted(i) for i in list(combinations(b, 3))]
a = [sorted(i) for i in a]

print("Yes" if any([bingo in combinated for bingo in a]) else "No")

Submission status: Wrong Answer

Solution code:
def mapt(fn, *args):
    return tuple(map(fn, *args))

a = [mapt(int, input().split(" ")) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

naname = (a[0][0], a[1][1], a[2][2])
a.append(naname)


def sear1(key):
    for x in range(n):
        for y in range(n):
            for z in range(n):
                if sorted((b[x],b[y],b[z])) == sorted(key):
                    print("Yes")
                    exit()
    print("No")



for i in a:
    sear1(i)

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)]
S=[[0,0,0] for _ in range(3)]
for b in B:
  for i in range(3):
    if b in A[i]:
      S[i][A[i].index(b)] = 1
      break
p = False
for a in S:
  if sum(a)==3:
    p = True
    break
if not p:
  for i in range(3):
    if S[0][i]+S[1][i]+S[2][i]==3:
      p = True
      break
if not p:
  if S[0][0]+S[1][1]+S[2][2]==3 or S[2][0]+S[1][1]+S[0][2]==3:
    p=True
print("Yes" if p else "No")
print(S)

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)]
S=[[0,0,0] for _ in range(3)]
for b in B:
  for i in range(3):
    if b in A[i]:
      S[i][A[i].index(b)] = 1
      break
p = False
for a in S:
  if sum(a)==3:
    p = True
    break
if not p:
  for i in range(3):
    if S[0][i]+S[1][i]+S[2][i]==3:
      p = True
      break
print("Yes" if p else "No")

Submission status: Wrong Answer

Solution code:
b = [[int(e) for e in input().split()] for _ in range(3)]
N = int(input())

for _ in range(N):
  x = int(input())

  for i in range(3):
    for j in range(3):
      if b[i][j] == x:
        b[i][j] = -1

ans = False
for i in range(3):
  if (b[i][:]) == [-1] * 3 or (b[:][i]) == [-1] * 3:
    ans = True

if ([b[0][0], b[1][1], b[2][2]]) == [-1] * 3 or ([b[0][2], b[1][1], b[2][0]]) == [-1] * 3:
  ans = True

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

Submission status: Wrong Answer

Solution code:
b = [[int(e) for e in input().split()] for _ in range(3)]
N = int(input())

for _ in range(N):
  x = int(input())

  for i in range(3):
    for j in range(3):
      if b[i][j] == x:
        b[i][j] = -1

ans = False
for i in range(3):
  if (b[i][:] == [-1] * 3) or (b[:][i] == [-1] * 3):
    ans = True

if ([b[0][0], b[1][1], b[2][2]] == [-1] * 3) or ([b[0][2], b[1][1], b[2][0]] == [-1] * 3):
  ans = True

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

Submission status: Wrong Answer

Solution code:
b = [[int(e) for e in input().split()] for _ in range(3)]
N = int(input())

for _ in range(N):
  x = int(input())

  for i in range(3):
    for j in range(3):
      if b[i][j] == x:
        b[i][j] = -1

ans = False
for i in range(3):
  if b[i][:] == [-1] * 3 or b[:][i] == [-1] * 3:
    ans = True

if [b[0][0], b[1][1], b[2][2]] == [-1] * 3 or [b[0][2], b[1][1], b[2][0]] == [-1] * 3:
  ans = True

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

Submission status: Wrong Answer

Solution code:
l = list(map(int,input().split()+input().split()+input().split()))
l1 = []
for i in range(int(input())):
  num = int(input())
  if num in l:
    l1.append(l.index(num))
  print(l1)
if (0 in l1 and 1 in l1 and 2 in l1) or (3 in l1 and 4 in l1 and 5 in l1) or (6 in l1 and 7 in l1 and 8 in l1) or (0 in l1 and 4 in l1 and 8 in l1) or (2 in l1 and 4 in l1 and 6 in l1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l = list(map(int,input().split()+input().split()+input().split()))
l1 = []
for i in range(int(input())):
  num = int(input())
  if num in l:
    l1.append(l.index(num))
    print(l1)
if (0 in l1 and 1 in l1 and 2 in l1) or (3 in l1 and 4 in l1 and 5 in l1) or (6 in l1 and 7 in l1 and 8 in l1) or (0 in l1 and 4 in l1 and 8 in l1) or (2 in l1 and 4 in l1 and 6 in l1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l = list(map(int,input().split()+input().split()+input().split()))
l1 = []
for i in range(int(input())):
  num = int(input())
  if num in l:
    l1.append(l.index(num))
if (0 and 1 and 2 in l1) or (3 and 4 and 5 in l1) or (6 and 7 and 8 in l1) or (0 and 4 and 8 in l1) or (2 and 4 and 6 in l1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l = list(map(int,input().split()+input().split()+input().split()))
l1 = []
for i in range(int(input())):
  num = int(input())
  if num in l:
    l1.append(l.index(num))
if (0 and 1 and 2 in l1) or (3 and 4 and 5 in l1) or (6 and 7 and 8 in l1) or (0 and 4 and 8 in l1) or (3 and 4 and 6 in l1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for bb in b:
    for i in range(3):
        for j in range(3):
            if l[i][j] == bb:
                ans[i][j] = 1

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

Submission status: Wrong Answer

Solution code:
arr = []
b = []
cmp_arr = [[False]*3]*3

for i in range(3):
  arr.append(list(map(int,input().split())))

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

for i in range(3):
  for j in range(3):
    for k in range(N):
      if arr[i][j] == b[k]:
        cmp_arr[i][j] = True

for i in range(3):
  if cmp_arr[i][0] and cmp_arr[i][1] and cmp_arr[i][2]:
    print("Yes");exit()
  if cmp_arr[0][i] and cmp_arr[1][i] and cmp_arr[2][i]:
    print("Yes");exit()
if cmp_arr[0][0] and cmp_arr[1][1] and cmp_arr[2][2]:
  print("Yes");exit()
if cmp_arr[0][2] and cmp_arr[1][1] and cmp_arr[2][0]:
  print("Yes");exit()
print("No")

Submission status: Wrong Answer

Solution code:
arr = []
b = []
cmp_arr = [[False]*3]*3

for i in range(3):
  arr.append(list(map(int,input().split())))

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

for i in range(3):
  for j in range(3):
    for k in range(N):
      if arr[i][j] == b[k]:
        cmp_arr[i][j] = True

for i in range(3):
  if cmp_arr[i][0] and cmp_arr[i][1] and cmp_arr[i][2]:
    print("Yes");exit()
  if cmp_arr[0][i] and cmp_arr[0][i] and cmp_arr[2][i]:
    print("Yes");exit()
if cmp_arr[0][0] and cmp_arr[1][1] and cmp_arr[2][2]:
  print("Yes");exit()
if cmp_arr[0][2] and cmp_arr[1][1] and cmp_arr[2][0]:
  print("Yes");exit()

print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

a = np.array([[int(i) for i in input().split()] for _ in range(3)])
N = int(input())
b = [int(input()) for i in range(N)]

for i in b:
    a=np.where(a==i,0,a)

flag = False
if False in np.all(a,axis=0):
    flag=True
if False in np.all(a,axis=1):
    flag=True
if a[0][0]==a[1][1]==a[2][2]==0:
    flag=True
if a[2][0]==a[1][1]==a[0][2]==0:
    flag=True
print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
l = []

for _ in range(3):
  l += list(map(int, input().split()))

n = int(input())
for _ in range(n):
  b = int(input())
  if b in l:
    l[l.index(b)] = 0

for i in range(3):
  if sum(l[0+3*i:3+3*i]) == 0:
    print("Yes")
    exit()
  
  if sum(l[i:8:3]) == 0:
    print("Yes")
    exit()

if (l[0]+l[4]+l[8]) == 0:
  print("Yes")
  exit()
if (l[2]+l[4]+l[6]) == 0:
  print("Yes")
  exit()
  
print("No")

Submission status: Wrong Answer

Solution code:
l = []

for _ in range(3):
  l += list(map(int, input().split()))

n = int(input())
for _ in range(n):
  b = int(input())
  if b in l:
    l[l.index(b)] = 0
    
for i in range(3):
  if sum(l[0+3*i:3+3*i]) == 0:
    print("Yes")
    exit()
  
  if sum(l[0+3*i:len(l):3]) == 0:
    print("Yes")
    exit()

if (l[0]+l[4]+l[8]) == 0:
  print("Yes")
  exit()
if (l[2]+l[4]+l[6]) == 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)]

a = []

Atf = [[False] * 3 for _ in range(3)]

for i in range(3):
    for aa in A[i]:
        a.append(aa)

for b in B:
    if b in a:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    Atf[i][j] = True

res = False

for i in range(3):
    if Atf[i][0] and Atf[i][1] and Atf[i][2]:
        res = True
        print(Atf[i][0])
        break
    elif Atf[0][i] and Atf[1][i] and Atf[2][i]:
        res = True
        break

if not res:
    if Atf[0][0] and Atf[1][1] and Atf[2][2]:
        res = True
    elif Atf[0][2] and Atf[1][1] and Atf[2][0]:
        res = True
 

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

Submission status: Wrong Answer

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

N = int(input())
B = [int(input()) for _ in range(N)]

a = []

Atf = [[False] * 3 for _ in range(3)]

for i in range(3):
    for aa in A[i]:
        a.append(aa)

for b in B:
    if b in a:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    Atf[i][j] = True

res = False

for i in range(3):
    if Atf[i][0] and Atf[i][1] and Atf[i][2]:
        res = True
        break
    elif A[0][i] and A[1][i] and A[2][i]:
        res = True
        break

if not res:
    if Atf[0][0] and Atf[1][1] and Atf[2][2]:
        res = True
    elif Atf[0][2] and Atf[1][1] and Atf[2][0]:
        res = True
 

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

Submission status: Wrong Answer

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

N = int(input())
B = [int(input()) for _ in range(N)]

a = []

Atf = [[0] * 3 for _ in range(3)]

for i in range(3):
    for aa in A[i]:
        a.append(aa)

res = False

for b in B:
    if b in a:
        ii = 0
        jj = 0
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    Atf[i][j] = 1
                    ii = i
                    jj = j

        if ii == jj:
            r = 1
            for i in range(3):
                r = min(r, Atf[i][i])

            if r == 1:
                res = True
                break

        else:
            r1 = 1
            r2 = 1
            for i in range(3):
                r1 = min(r1, Atf[ii][i])
                r2 = min(r2, Atf[i][jj])

            if r1 == 1 or r2 == 1:
                res = True
                break

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

Submission status: Wrong Answer

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

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(9):
        if a[i] == b:
            a[i] = 0

# print(a)
for i in range(3):
    if sum(a[i*3:i*3+3]) == 0:
        print('Yes')
        exit()
    if sum(a[i:3:9]) == 0:
        print('Yes')
        exit()

if (a[0] + a[4] + a[8]) == 0:
    print('Yes')
    exit()
if (a[2] + a[4] + a[6]) == 0:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
a = []
for _ in range(3):
    a.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 b == a[i][j]:
                a[i][j] = 0

for i in range(3):
    if sum(a[i]) == 0:
        print('Yes')
        exit()
    sum_a = 0
    for j in range(3):
        sum_a += a[i][j]
    if sum_a == 0:
        print('Yes')
        exit()
if (a[0][0] + a[1][1] + a[2][2]) == 0:
    print('Yes')
    exit()
if (a[0][2] + a[1][1] + a[2][0]) == 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 = [input() for _ in range(N)]


cnt=0

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                a[j][k] =1000
                if sum(a[j]) ==3000 or a[0][k]+a[1][k]+a[2][k]==3000 or a[0][0]+a[1][1]+a[2][2]==3000 or a[0][2]+a[1][1]+a[2][0]==3000:
                    cnt +=1
print('Yes' if cnt>0 else 'No')

Submission status: Wrong Answer

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


cnt=0

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                a[j][k] =1000
            if sum(a[j]) ==3000 or a[0][k]+a[1][k]+a[2][k]==3000 or a[0][0]+a[1][1]+a[2][2]==3000 or a[0][2]+a[1][1]+a[2][0]==3000:
                cnt +=1
print('Yes' if cnt>0 else 'No')

Submission status: Wrong Answer

Solution code:
bingo = [list(map(int, input().split())) for _ in range(3)]
def chec_line():
    ret = False
    for i in range(3):
        cnt = 0
        for j in range(3):
            if bingo[i][j] == -1:
                cnt += 1
        if cnt == 3:
            ret =True

    for i in range(3):
        cnt = 0
        for j in range(3):
            if bingo[j][i] == -1:
                cnt += 1
        if cnt == 3:
            ret =True
    cnt = 0
    for i in range(3):
        if bingo[i][i] == -1:
            cnt += 1
    if cnt == 3:
        ret =True
        cnt = 0

    for i in range(3):
        if bingo[2-i][i] == -1:
            cnt += 1
    if cnt == 3:
        ret =True

    return ret
def check_num( num):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                bingo[i][j] = -1
                

n = int(input())
flag = False
for _ in range(n):
    check_num(int(input()))
    flag = chec_line() 
    if flag:
        break
if flag :
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

n=int(input())

b=[int(input()) for i in range(n)]
#print(list_2d)
#print(b)
 
#印をつける
for i in range(3):
    for j in range(3):
        if list_2d[i][j] in b:
            list_2d[i][j]="x"
            
#print(list_2d)

#ビンゴかどうかチェックする
#横
if list_2d[0]==["x","x","x"] or list_2d[1]==["x","x","x"] or list_2d[0]==["x","x","x"]:
    ans="Yes"
    
#縦
elif list_2d[0][0]==list_2d[1][0]==list_2d[2][0]=="x" or  list_2d[0][1]==list_2d[1][1]==list_2d[2][1]=="x" or  list_2d[0][2]==list_2d[1][2]==list_2d[2][2]=="x":
    ans="Yes"

#斜め
elif  list_2d[0][0]==list_2d[1][1]==list_2d[2][2]=="x" or  list_2d[0][2]==list_2d[1][1]==list_2d[2][0]=="x":
    ans="Yes"
    
else:
    ans="No"
    
print(ans)

Submission status: Wrong Answer

Solution code:
a = [0] * 3
for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
b = set()
for _ in range(n):
    b.add(int(input()))

if (
    set(a[0]) <= b
    or set(a[1]) <= b
    or set(a[2]) <= b
    or set(a[:][0]) <= b
    or set(a[:][1]) <= b
    or set(a[:][2]) <= b
    or {a[0][0], a[1][1], a[2][2]} <= b
    or {a[0][2], a[1][1], a[2][0]} <= b
):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

N = int(input())

def ball(b):
    global A
    for c in range(3):
        for co in range(3):
            if A[c][co] == b:
                A[c][co] = "ok"


for c in range(N):
    b = int(input())
    ball(b)



if A[0].count("ok") == 3 or A[0].count("ok") == 3 or A[0].count("ok") == 3:
    print("Yes")
elif A[0][0] == "ok" and A[1][0] == "ok" and A[2][0] == "ok":
    print("Yes")
elif A[0][1] == "ok" and A[1][1] == "ok" and A[2][1] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][2] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][0] == "ok" and A[1][1] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][1] == "ok" and A[2][0] == "ok":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
a = [[input().split() for l in range(3)]]
a = np.ravel(a)
n = int(input())
b = [input() for i in range(n)]
ans = 'No'

def check(a,b):
    return set(a).issubset(b)

for i in range(3):
    if check(a[i*3:(i*3)+3],b) or check(a[i:i+6:3],b) or check(a[0:8:4],b) or check(a[2:6:2],b):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
a = [[input().split() for l in range(3)]]
a = np.ravel(a)
n = int(input())
b = [input() for i in range(n)]
ans = 'No'

def check(a,b):
    return set(a).issubset(b)

for i in range(3):
    print(a[i*3:(i*3)+2])
    if check(a[i*3:(i*3)+3],b) or check(a[i:i+6:3],b) or check(a[0:8:4],b) or check(a[2:6:2],b):
        ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
# ABC157 B
import numpy as np
a = [list(input()) for i in range(3)]
a = np.ravel(a)
n = int(input())
b = [input() for i in range(n)]
ans = 'No'
for i in b:
    for j in range(3):
        if i in a[j*3:j*3+2] or i in a[j:j+6:3]:
            ans = 'Yes'
    if i in a[0:8:4] or i in a[2:6:2]:
        ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
a1=input("").split(" ")
a2=input("").split(" ")
a3=input("").split(" ")
lista=[]
listmp=[]
for k in range(3):
    listmp+=[int(a1[k])]
lista+=[listmp]
listmp=[]
for k in range(3):
    listmp+=[int(a2[k])]
lista+=[listmp]
listmp=[]
for k in range(3):
    listmp+=[int(a3[k])]
lista+=[listmp]
n=int(input(""))
listn=[]
for i in range(n):
    t=int(input(""))
    listn+=[t]
for i in range(3):
    for k in range(3):
        if(lista[i][k] in listn):
            lista[i][k]=0
p=0
for i in range(3):
    s=0
    for k in range(3):
        s+=lista[i][k]

        if(s==0):
            p=1
for i in range(3):
    s=0
    for k in range(3):
        s+=lista[k][i]

        if(s==0):
            p=1
s=0
for i in range(3):
    s+=lista[i][i]
if(s==0):
    p=1
s=0
for i in range(3):
    s+=lista[i][2-i]
if(s==0):
    p=1
if(p==1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

import numpy as np

for i in range(3):
  a[i]=[1 if x in b else 0 for x in a[i]]   

s_1=max(np.sum(a,axis=0))
s_2=max(np.sum(a,axis=1))
s_3=a[0][0]+a[1][1]+a[2][2]
s_4=a[0][2]+a[1][1]+a[2][0]

if max(s_1,s_2,s_3,s_4)==3:
  print("Yes")
else:
  print("No")
print(a)

Submission status: Wrong Answer

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

import numpy as np

l=[[0]*3]*3
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      l[i][j]=1
s_1=max(np.sum(l,axis=0))
s_2=max(np.sum(l,axis=1))
s_3=l[0][0]+l[1][1]+l[2][2]
s_4=l[0][2]+l[1][1]+l[2][0]

if max(s_1,s_2,s_3,s_4)==3:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np


def check_bingo(A):
    for i in range(3):
        if np.all(A[i] == -1) or np.all(A[:, i] == -1):
            return 'Yes'
    if np.all(A[list(range(3)), list(range(3))] == -1):
        return 'Yes'

    return 'No'


def main():
    A = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    for i in range(n):
        b = int(input())
        A = np.where(A == b, -1, A)
    ans = check_bingo(A)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def check_bingo(A):
    for i in range(3):
        if np.all(A[i] == 0) or np.all(A[:, i] == 0):
            return 'Yes'
    if np.all(A[list(range(3)), list(range(3))] == 0):
        return 'Yes'

    return 'No'


def main():
    A = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    for i in range(n):
        b = int(input())
        A = np.where(A == b, 0, A)
    ans = check_bingo(A)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def check_bingo(A):
    for i in range(3):
        if not np.all(A[i]) or not all(A[:, i]):
            return 'Yes'
    if not np.all(A[list(range(3)), list(range(3))]):
        return 'Yes'

    return 'No'


def main():
    A = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    for i in range(n):
        b = int(input())
        A = np.where(A == b, 0, A)
    ans = check_bingo(A)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
card = [ list(map(int,input().split())) for a in range(3) ]
N = int(input())
point = [ int(input()) for a in range(N) ]

# cut holes
for I in point:
    for J in card:
        if I in J:
            J.index(I)
            J[J.index(I)] = "H"
print(card)
# vertical check
for K in range(3):
    check = set([ x[K] for x in card ])
    if len(check) == 1 and list(check)[0] == "H":
        print('Yes')
        sys.exit()
# horizon check
for L in card:
    check = set(L)
    if len(check) == 1 and list(check)[0] == "H":
        print('Yes')
        sys.exit()
# diagonal check
LtoR = set([ card[M][M] for M in range(3)])
RtoL = set([ card[M][-M-1] for M in range(3)])
if len(LtoR) == 1 and list(LtoR)[0] == "H" or  len(RtoL) == 1 and list(RtoL)[0] == "H":    
    print('Yes')
    sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
import sys
card = [ list(map(int,input().split())) for a in range(3) ]
N = int(input())
point = [ int(input()) for a in range(N) ]

# cut holes
for I in point:
    for J in card:
        if I in J:
            J.index(I)
            J[J.index(I)] = "H"
# vertical check
for K in range(3):
    check = set([ x[K] for x in card ])
    if len(check) == 1 and list(check)[0] == "H":
        print('Yes')
        sys.exit()
# horizon check
for L in card:
    check = set(L)
    if len(check) == 1 and list(check)[0] == "H":
        print('Yes')
        sys.exit()
# diagonal check
for M in range(3):
    if card[M][M] == "H" or card[-(M-1)][-(M-1)] == "H":
        print('Yes')
        sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

A = [int(x) for x in input().split()] + [int(x) for x in input().split()] + [int(x) for x in input().split()]
N = int(input())
B = []
for i in range(N):
    B.append(int(input()))

C = [
    ["x","x","x",],
    ["x","x","x",],
    ["x","x","x",],
    ]

for b in B:
    if b in A:
        pos = A.index(b)
        C[pos // 3][pos % 3] = "o"

if C[0].count("o") == 3 or C[1].count("o") == 3 or C[2].count("o") == 3:
    print("Yes")
elif C[0][0] == "o" and C[1][1] == "o" and C[2][2] == "o":
    print("Yes")
elif C[0][2] == "o" and C[1][1] == "o" and C[2][0] == "o":
    print("Yes")
elif C[0][0] == "o" and C[0][1] == "o" and C[0][2] == "o":
    print("Yes")
elif C[1][0] == "o" and C[1][1] == "o" and C[1][2] == "o":
    print("Yes")
elif C[2][0] == "o" and C[2][1] == "o" and C[2][2] == "o":
    print("Yes")
else:
    print("No")