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:
la=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=list(map(int,input().split()))
 
for list in la:
  for _ in range(3):
     if list[_] in b:
        list[_]=101
for list in la:
  if all(aa==101 for aa in list):
     print('Yes')
     exit()
tate=[[]]*3
for list in la:
   tate[0].append(list[0])
   tate[1].append(list[1])
   tate[2].append(list[2])
for t in tate:
   if all(tt==101 for tt in t):
       print('Yes')
       exit()
 
if all(xx==101 for xx in [la[0][0],la[1][1],la[2][2]]):
  print('Yes')
  exit()
 
if all(yy==101 for yy in [la[0][2],la[2][2],la[2][0]]):
  print('Yes')
  exit()
print('No')

Submission status: Wrong Answer

Solution code:
la=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=list(map(int,input().split()))
 
for list in la:
  for _ in range(3):
     if list[_] in b:
        list[_]=101
for list in la:
  if all(aa==101 for aa in list):
     print('Yes')
     exit()
tate=[[]]*3
for list in la:
   for _ in range(3):
       tate[_].append(list[_])
for t in tate:
   if all(tt==101 for tt in t):
       print('Yes')
       exit()

if all(xx==101 for xx in [la[0][0],la[1][1],la[2][2]]):
  print('Yes')
  exit()

if all(yy==101 for yy in [la[0][2],la[2][2],la[2][0]]):
  print('Yes')
  exit()
print('No')

Submission status: Wrong Answer

Solution code:
import itertools

def judge():
  for i in range(3):
    if A[i*3 + 0] + A[i*3 + 1] + A[i*3 + 2]  == 0 or A[0 + i] + A[1 + i] + A[2 + i]  == 0:
      return True
  if A[0*3 + 0] + A[1*3 + 1] + A[2*3 + 2]  == 0 or A[2*3 + 0] + A[1*3 + 1] + A[0*3 + 2]  == 0:
    return True
  return False

A_2d=[list(map(int,list(input().split()))) for i in range(3)]
A=list(itertools.chain.from_iterable(A_2d)) # A_1d

N = int(input())

for _ in range(N):
  b = int(input())
  A = [0 if i == b else i for i in A]
  
if judge():
  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())
for i in range(n):
    b = int(input())
    a1 = [0 if i == b else i for i in a1]
    a2 = [0 if i == b else i for i in a2]
    a3 = [0 if i == b else i for i in a3]
    
if a1[0] == a2[0] == a3[0] == 0 or a1[1] == a2[1] == a3[1] == 0 or a1[2] == a2[2] == a3[2] == 0 or a1[0] == a2[1] == a3[2] == 0 or a1[2] == a2[1] == a3[0] == 0:
    print('Yes') 
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def resolve():
    a = [[int(i) for i in input().split()] for _ in range(3)]
    ans = 'No'
    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

                if sum(a[i]) == 0 or sum([a[0][i], a[1][i], a[2][i]]) == 0:
                    ans = 'Yes'
                elif sum([a[0][0], a[1][1], a[2][2]]) == 0 or sum([a[0][2], a[1][1], a[2][0]]) == 0:
                    ans = 'Yes'

    print(ans)

resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    a = [[int(i) for i in input().split()] for _ in range(3)]
    ans = 'No'
    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

                _a = list(zip(*a))
                if sum(a[i]) == 0 or sum(_a[i]) == 0:
                    ans = 'Yes'
                elif sum([a[0][0], a[1][1], a[2][2]]) == 0 or sum([a[0][2], a[1][1], a[2][0]]) == 0:
                    ans = 'Yes'

    print(ans)

resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    import sys
    a = [[int(i) for i in input().split()] for _ in range(3)]
    for i in range(3):
        a.append([a[0][i], a[1][i], a[2][i]])

    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

                _a = list(zip(*a))
                if sum(a[i]) == 0 or sum(_a[i]) == 0:
                    print('Yes')
                    sys.exit()
                elif sum([a[0][0], a[1][1], a[2][2]]) == 0 or sum([a[0][2], a[1][1], a[2][0]]) == 0:
                    print('Yes')
                    sys.exit()

    print('No')

resolve()

Submission status: Wrong Answer

Solution code:
import sys
table = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
    cmd = int(input())
    for i in range(3):
        for j in range(3):
            if table[i][j] == cmd:
                table[i][j] = -1
                break
for i in range(3):
    if (table[i][0]==-1 and table[i][1]==-1 and table[i][2]) or \
        (table[0][i]==-1 and table[1][i]==-1 and table[2][i]):
        print("Yes")
        sys.exit()
if (table[0][0]==-1 and table[1][1]==-1 and table[2][2]==-1) or \
    (table[0][2]==-1 and table[1][1]==-1 and table[2][0]==-1):
    print("Yes")
    sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys
table = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for _ in range(N):
    cmd = int(input())
    for i in range(3):
        for j in range(3):
            if table[i][j] == cmd:
                table[i][j] = -1
                break
for i in range(3):
    if (table[i][0]==-1 and table[i][1]==-1 and table[i][2]) or \
        (table[0][i]==-1 and table[1][i]==-1 and table[2][i]):
        print("Yes")
        sys.exit()
if table[0][0]==-1 and table[1][1]==-1 and table[2][2]==-1:
    print("Yes")
    sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = []
for _ in range(N) :
    b = int(input())
    for x in range(3) :
        for y in range(3) :
            if A[x][y] == b :
                A[x][y] = -1
for y in range(3) :
    f = True
    for x in range(3) :
        if A[x][y] != -1 :
            f = False
    if f :
        print('Yes')
        exit()

f = True
for y in range(3) :
    if A[y][y] != -1 :
        f = False
if f :
    print('Yes')
    exit()

f = True
for y in range(3) :
    if A[2 - y][y] != -1 :
        f = False
if f :
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
card=[]
for i in range(3):
  card.append(list(map(int,input().split())))
n = int(input())
for i in range(n):
  k = int(input())
  for i in range(3):
    for j in range(3):
      if k == card[i][j]:
        card[i][j] = -1

bingo=False
for i in range(3):
  s=list(set(card[i]))
  if len(s) == 1 and s[0] == -1:
    bingo=True
for i in range(3):
  if card[i][0] == -1 and card[i][1] == -1 and card[i][2] == -1:
    bingo=True
if card[0][0] == -1 and card[1][1] == -1 and card[2][2] == -1:
  bingo=True
if card[2][0] == -1 and card[1][1] == -1 and card[0][2] == -1:
  bingo=True
if bingo:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
card=[]
for i in range(3):
  card.append(list(map(int,input().split())))
n = int(input())
for i in range(n):
  k = int(input())
  for i in range(3):
    for j in range(3):
      if k == card[i][j]:
        card[i][j] = -1

bingo=False
for i in range(3):
  s=list(set(card[i]))
  if len(s) == 1 and s[0] == -1:
    bingo=True
for i in range(3):
  if card[i][0] == -1 and card[i][1] == -1 and card[i][2] == -1:
    bingo=True
if card[0][0] == -1 and card[1][1] == -1 and card[2][2] == -1:
  bingo=True
if card[2][0] == -1 and card[1][1] == -1 and card[2][0] == -1:
  bingo=True
if bingo:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
card = [0]*3
for i in range(3):
    a = input().split()
    card[i] = [int(s) for s in a]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == card[j][k]:
                card[j][k] = 0
if (card[0][0] == 0 and card[1][0] == 0 and card[2][0] == 0) or (card[0][1] == 0 and card[1][1] == 0 and card[2][1] == 0) or (card[0][2] == 0 and card[1][2] == 0 and card[2][2] == 0) or(card[0][0] == 0 and card[0][1] == 0 and card[0][2] == 0) or (card[1][0] == 0 and card[1][1] == 0 and card[1][2] == 0) or (card[2][0] == 0 and card[2][1] == 0 and card[2][2] == 0) or (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or (card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0):
    print("Yes")
else:
    ("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    A = LLI(3)
    # print(A)
    n = II()
    C = [[0, 0, 0] for _ in range(3)]
    # print(C)
    for i in range(n):
        b = II()
        for j in range(3):
            for k in range(3):
                if A[j][k] == b:
                    C[j][k] = 1

    # print(C)
    # tate, yoko
    for i in range(3):
        if sum(C[:][i]) == 3 or sum(C[i][:]) == 3:
            print('Yes')
            return

    # naname
    if C[0][0] + C[1][1] + C[2][2] == 3 or C[0][2] + C[1][1] + C[2][0] == 3:
        print('Yes')
        return

    print('No')



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
dic = {}
for i in range(3):
  arr = input().split()
  for j in range(3):
    dic[arr[j]] = (i,j)
    
n = int(input())
appear=[[False]*3]*3

for _ in range(n):
  b = input()
  if b in dic:
    i, j = dic[b]
    appear[i][j] = True

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

if appear[0][0] and appear[1][1] and appear[2][2]:
  ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
  ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
dic = {}
for i in range(3):
  arr = list(map(int, input().split()))
  for j in range(3):
    dic[arr[j]] = (i,j)
    
n = int(input())
appear=[[False]*3]*3

for _ in range(n):
  b = int(input())
  if b in dic:
    i, j = dic[b]
    appear[i][j] = True

ans = 'No'
for i in range(3):
  if appear[i][0] and appear[i][1] and appear[i][2]:
    ans = 'Yes'
    break
  if appear[0][i] and appear[1][i] and appear[2][i]:
    ans = 'Yes'
    break
if appear[0][0] and appear[1][1] and appear[2][2]:
  ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
  ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
dic = {}
for i in range(3):
  ar = list(map(int, input().split()))
  for j in range(3):
    dic[ar[j]] = (i+1)*10 + j+1
 
se = set()
n = int(input())
for _ in range(n):
  b = int(input())
  if b in dic:
    se.add(dic[b])
 
if 11 in se:
  if 12 in se and 13 in se:
    print('Yes')
  elif 21 in se and 31 in se:
    print('Yes')
  elif 22 in se and 33 in se:
    print('Yes')
elif 21 in se:
  if 22 in se and 23 in se:
    print('Yes')
elif 31 in se:
  if 32 in se and 33 in se:
    print('Yes')
  elif 22 in se and 13 in se:
    print('Yes')
elif 13 in se and 23 in se and 33 in se:
  print('Yes')
elif 12 in se and 22 in se and 32 in se:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
dic = {}
for i in range(3):
  ar = list(map(int, input().split()))
  for j in range(3):
    dic[ar[j]] = (i+1)*10 + j+1

se = set()
n = int(input())
for _ in range(n):
  b = int(input())
  if b in dic:
    se.add(dic[b])

if 11 in se:
  if 12 in se and 13 in se:
    print('Yes')
  elif 21 in se and 31 in se:
    print('Yes')
  elif 22 in se and 33 in se:
    print('Yes')
elif 21 in se:
  if 22 in se and 23 in se:
    print('Yes')
elif 31 in se:
  if 32 in se and 33 in se:
    print('Yes')
  elif 22 in se and 13 in se:
    print('Yes')
elif 13 in se and 23 in se and 33 in se:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

num = [[0] * 3 for _ in range(3)]
for i in range(n):
    x = int(input())
    for j in range(3):
        for k in range(3):
            if x == a[j][k]:
                num[j][k] = 1

cnt = 0
ans = False
for i in range(3):
    for j in range(3):
        if num[i][j] == 1:
            cnt += 1
    if cnt == 3:
        ans = True

for i in range(3):
    for j in range(3):
        if num[j][i] == 1:
            cnt += 1
    if cnt == 3:
        ans = True

if num[0][0] == 1 and num[1][1] == 1 and num[2][2] == 1:
    ans = True
if num[0][2] == 1 and num[1][1] == 1 and num[2][0] == 1:
    ans = True

if ans:
    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 = []
for _ in range(N):
    B.append(input())
    
for b in B:
    for x in range(3):
        for y in range(3) :
            if A[x][y] == b:
                A[x][y] = 0
if A[0][0] + A[1][0] + A[2][0] == 0 \
or A[0][1] + A[1][1] + A[2][1] == 0 \
or A[0][2] + A[1][2] + A[2][2] == 0 \
or A[0][0] + A[0][1] + A[0][2] == 0 \
or A[1][0] + A[1][1] + A[1][2] == 0 \
or A[2][0] + A[2][1] + A[2][2] == 0 \
or A[0][0] + A[1][1] + A[2][2] == 0 \
or A[0][2] + A[1][1] + A[2][0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [list(int(i) for i in input().split()) for i in range(3)]
f = [[0 for i in range(3)] for i in range(3)]
n = int(input())
b = []
flag = False

for i in range(n):
  b.append(int(input()))
  
for i in b:
  for j in range(3):
    for k in range(3):
      if i == a[j][k]:
        f[j][k] = 1
        
if sum(f[0]) == 3 or sum(f[1]) == 3 or sum(f[2]) == 3:
  flag = True

for i in range(3):
  tmp = []
  for j in range(3):
    tmp.append(f[j][i])
  if sum(tmp) == 3:
    flag == True
    
if f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
  flag = True

if f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
  flag = True

if flag == True:
  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 = []
for _ in range(N):
    B.append(input())
for b in B:
    for x in range(3):
        for y in range(3) :
            if A[x][y] == b:
                A[x][y] = 0
if A[0][0] * A[1][0] * A[2][0] == 0 \
or A[0][1] * A[1][1] * A[2][1] == 0 \
or A[0][2] * A[1][2] * A[2][2] == 0 \
or A[0][0] * A[0][1] * A[0][2] == 0 \
or A[1][0] * A[1][1] * A[1][2] == 0 \
or A[2][0] * A[2][1] * A[2][2] == 0 \
or A[0][0] * A[1][1] * A[2][2] == 0 \
or A[0][2] * A[1][1] * A[2][0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for b in B:
    for x in range(3):
        for y in range(3) :
            if A[x][y] == b:
                A[x][y] = 0

if A[0][0] * A[1][0] * A[2][0] == 0 or A[0][1] * A[1][1] * A[2][1] == 0 or A[0][2] * A[1][2] * A[2][2] == 0 or A[0][0] * A[0][1] * A[0][2] == 0 or A[1][0] * A[1][1] * A[1][2] == 0 or A[2][0] * A[2][1] * A[2][2] == 0 or A[0][0] * A[1][1] * A[2][2] == 0 or A[0][2] * A[1][1] * A[2][0] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for Row in range(3):
        for Col in range(3):
            if b==A[Row][Col]:
                A[Row][Col]=0  

print(A)

Submission status: Wrong Answer

Solution code:
a=list(list(0 for i in range(3)) for i in range(3))
b=list(list(0 for i in range(3)) for i in range(3))
for i in range(3):
    a[i][0],a[i][1],a[i][2]=map(int,input().split())
n=int(input())
for i in range(n):
    s=int(input())
    for j in range(3):
        for k in range(3):
            if(a[j][k]==s):
                b[j][k]=1
if(b[0][0]+b[1][1]+b[2][2]==3 or b[2][0]+b[1][1]+b[0][2]==3):
    print("Yes")
elif(sum(b[0])==3 or sum(b[1])==3 or sum(b[2])==3):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
a1 = np.zeros(3, dtype=int)
a2 = np.zeros(3, dtype=int)
a3 = np.zeros(3, dtype=int)

for i in range(3):
    a1[i], a2[i], a3[i] = map(int, input().split())

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

a = np.array([a1, a2, a3]).T.flatten()

for i in range(n):
    a[np.where(a == b[i])] = 0
a = a.reshape(3, -1)

print("Yes") if a[0].sum()==0 or a[1].sum()==0 or a[2].sum()==0 or a[:, 0].sum()==0 or a[:, 1].sum()==0 or a[:, 2].sum()==0 or np.diag(a).sum()==0 or np.diag(a[::-1]).sum()==0 else "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=[int(input()) for i in range (N)]
for t in b:
    if t in A1:
        A1[A1.index(t)]="#"
    elif t in A2:
        A2[A2.index(t)]="#"
    elif t in A3:
        A3[A3.index(t)]="#"
ans='No'
if len(set(A1))==1 or len(set(A2))==1 or len(set(A2))==1:
    ans='Yes'
if (A1[0]==A2[0]==A3[0]) or (A1[1]==A2[1]==A3[1]) or (A1[2]==A2[2]==A3[2]):
    ans='Yes'
if (A1[0]==A2[1]==A3[2]) or (A1[2]==A2[1]==A3[0]):
    ans='Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
A = np.zeros((3,3), dtype=int)
for i in range(3):
    A[i,:] = list(map(int, input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]

A = A.flatten()
for a in range(len(A)):

    for b in range(N):
        if A[a] == B[b]:
            A[a] = -1

print(A.reshape(3,3))

if A[0] == -1 and A[1] == -1 and A[2] == -1:
    print('Yes')
elif A[3] == -1 and A[4] == -1 and A[5] == -1:
    print('Yes')
elif A[6] == -1 and A[7] == -1 and A[8] == -1:
    print('Yes')
elif A[0] == -1 and A[3] == -1 and A[6] == -1:
    print('Yes')
elif A[1] == -1 and A[4] == -1 and A[6] == -1:
    print('Yes')
elif A[2] == -1 and A[5] == -1 and A[8] == -1:
    print('Yes')
elif A[0] == -1 and A[4] == -1 and A[8] == -1:
    print('Yes')
elif A[2] == -1 and A[4] == -1 and A[6] == -1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def solve():
    A = [list(map(int, input().split())) for _ in range(3)]
    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] = -1
    
    for i in range(3):
        if A[i][0] == -1 and A[i][1] == -1 and A[i][2] == -1:
            return "Yes"
    for j in range(3):
        if A[0][j] == -1 and A[0][j] == -1 and A[0][j] == -1:
            return "Yes"
    if A[0][0] == -1 and A[1][1] == -1 and A[2][2] == -1:
        return "Yes"
    if A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1:
        return "Yes"
    return "No"

print(solve())

Submission status: Wrong Answer

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

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

for i in range(3):
    if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0 :
        print("Yes")
        exit()
    elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0 :
        print("Yes")
        exit()
    elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        print("Yes")
        exit()
    elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Submission status: Wrong Answer

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

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

for i in range(3):
    if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0 :
        print("Yes")
        exit()
    elif a[0][i] == 0 and a[0][i] == 0 and a[0][i] == 0 :
        print("Yes")
        exit()
    elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        print("Yes")
        exit()
    elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

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 = []
for _ in range(N):
    B.append(int(input()))
             
for k in range(3):
    for j in range(3):
        if A[k][j] in B:
             A[k][j] = 0
answer = 'No'
for i in range(3):
    if sum(A[i])==0:
        answer = 'Yes'
        break
    count = 0
    for j in range(3):
        count += A[j][i]
        if count == 0:
            answer = 'Yes'
if A[0][0]+A[1][1]+A[2][2]==0:
    answer = 'Yes'
if A[0][2]+A[1][1]+A[2][0]==0:
    answer = 'Yes'
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
bs = [int(input()) for _ in range(N)]

A = np.array([A1, A2, A3])
mask = np.zeros_like(A)
for b in bs:
    mask += (A==b).astype(int)

mask = mask>0
if np.any(np.all(mask, axis=0)):
    print('Yes')
elif np.any(np.all(mask, axis=1)):
    print('Yes')
elif np.all(np.diag(mask)):
    print('Yes')
elif np.all(np.diag(mask.T)):
    print('Yes')
else:
    print('No')

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 = []
for _ in range(N):
    B.append(int(input()))
             
for k in range(3):
    for j in range(3):
        if A[k][j] in B:
             A[k][j] = 0
answer = 'No'
for i in range(3):
    if sum(A[i])==0:
        answer = 'Yes'
        break
    count = 0
    for j in range(3):
        count += A[j][i]
        if count == 0:
            answer = 'Yes'
    if A[0][0]+A[1][1]+A[2][2]==0:
        answer = 'Yes'
    if A[0][2]+A[1][1]+A[2][0]==0:
        answer = 'Yes'
print(answer)

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 = []
for _ in range(N):
    B.append(int(input()))
             
for k in range(3):
    for j in range(3):
        if A[k][j] in B:
             A[k][j] = 0
answer = 'No'
for i in range(3):
    if sum(A[i])==0:
        answer = 'Yes'
        break
    count = 0
    for j in range(3):
        count += A[j][i]
print(answer)

Submission status: Wrong Answer

Solution code:
A = [[0 for _ in range(3)] for _ in range(3)]
B = [[False for _ in range(3)] for _ in range(3)]
b = []

for i in range(3):
    A[i][0],A[i][1],A[i][2] = 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 b[k]==A[i][j]:
                B[i][j]=True

judge = False

count3=0
count4=0

for i in range(3):
    count1=0
    count2=0
    
    if B[i][i]==True:
        count3 += 1
        if count3==3:
            judge=True
            break
        
    elif B[2-i][i]==True:
        count4 +=1
        if count4==3:
            judge=True
            break
    
    for j in range(3):
        if B[i][j]==True:
            count1 += 1
            if count1 == 3:
                judge = True
                break
            
        elif B[j][i]==True:
            count2 += 1
            if count2 == 3:
                judge = True
                break
if judge==True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = [[0 for _ in range(3)] for _ in range(3)]
B = [[False for _ in range(3)] for _ in range(3)]
b = []

for i in range(3):
    A[i][0],A[i][1],A[i][2] = 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 b[k]==A[i][j]:
                B[i][j]=True

judge = False

count3=0
count4=0

for i in range(3):
    count1=0
    count2=0
    
    if B[i][i]==True:
        count3 += 1
        if count3==3:
            judge=True
    elif B[2-i][i]==True:
        count4 +=1
        if count4==3:
            judge=True
    
    for j in range(3):
        if B[i][j]==True:
            count1 += 1
            if count1 == 3:
                judge = True
                break
        elif B[j][i]==True:
            count2 += 1
            if count2 == 3:
                judge = True
                break
if judge==True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
a = []
for i in range(3):
    array = list(map(int, input().strip().split()))
    a.append(array)
n = int(input())
b = [int(input()) for i in range(n)]
count_i = []
count_j = []
count_x = 0
ans_0 = 0
ans_1 = 0
ans_2 = 0
ans_3 = 0
ans_4 = 0
ans_5 = 0
for l in range(n):
    for i in range(3):
        for j in range(3):
            if b[l] == a[i][j]:
                count_i.append(i)
                count_j.append(j)
                if i == j:
                    count_x += 1
                    if count_x == 3:
                        print("Yes")
                        sys.exit()
            else:
                count_i.append(-1)
                count_j.append(-1)
    
for i in range(n):
    if count_i[i] == 0:
        ans_0 += 1
    elif count_i[i] == 1:
        ans_1 += 1
    elif count_i[i] == 2:
        ans_2 += 1
    
    if count_j[i] == 0:
        ans_3 += 1
    elif count_j[i] == 1:
        ans_4 += 1
    elif count_j[i] == 2:
        ans_5 += 1

if ans_0 >=3:
    print("Yes")
elif ans_1 >= 3:
    print("Yes")
elif ans_2 >= 3:
    print("Yes")
else:
    print("No")
"""
elif ans_3 >= 3:
    print("Yes")
elif ans_4 >= 3:
    print("Yes")
elif ans_5 >= 3:
    print("Yes")
else:
    print("No")
"""

Submission status: Wrong Answer

Solution code:
import sys
a = []
for i in range(3):
    array = list(map(int, input().strip().split()))
    a.append(array)
n = int(input())
b = [int(input()) for i in range(n)]
count_i = []
count_j = []
count_x = 0
for l in range(n):
    for i in range(3):
        for j in range(3):
            if b[l] == a[i][j]:
                count_i.append(i)
                count_j.append(j)
                if i == j:
                    count_x += 1
                    if count_x == 3:
                        print("Yes")
                        sys.exit()
            else:
                count_i.append(-1)
                count_j.append(-1)
    
ans_0 = 0
ans_1 = 0
ans_2 = 0
ans_3 = 0
ans_4 = 0
ans_5 = 0
for i in range(n):
    if count_i[i] == 0:
        ans_0 += 1
    elif count_i[i] == 1:
        ans_1 += 1
    elif count_i[i] == 2:
        ans_2 += 1
    
    if count_j[i] == 0:
        ans_3 += 1
    elif count_j[i] == 1:
        ans_4 += 1
    elif count_j[i] == 2:
        ans_5 += 1

if ans_0 >=3:
    print("Yes")
elif ans_1 >= 3:
    print("Yes")
elif ans_2 >= 3:
    print("Yes")
elif ans_3 >= 3:
    print("Yes")
elif ans_4 >= 3:
    print("Yes")
elif ans_5 >= 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# input
A = []
A_append = A.append
for i in range(3):
    An = list(map(int, input().split()))
    A_append(An)
print(A)

N = int(input())

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

# check

marker = [[0 * 3], [0 * 3], [0 * 3]]
bingo_fl = False
for i in b:
    if b in A:
        n, m = A.index(b)
        marker[n][m] = 1

        if (
            [1 * 3] in [marker[i][:] for i in range(3)] or
            [1 * 3] in [[marker[0][i], marker[1][i], marker[2][i]] for i in range(3)] or
            [1 * 3] == [marker[0][0], marker[1][1], marker[2][2]] or
            [1 * 3] == [marker[0][2], marker[1][1], marker[2][0]]
        ):
            bingo_fl = True
            break

if bingo_fl is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
L = list(list(map(int,input().split())) for i in range(3))
n = int(input())
ls = [int(input()) for j in range(n)]
lsls = [0]
lsls[0] = L[0] + L[1] + L[2]
for k in range(n):
    for l in range(9):
        if ls[k] == lsls[0][l]:
            lsls[0][l] = 0
for r in range(3):
    b = [e for e in lsls[0]]
    a = b[r::3]
    if (sum(L[r]) ==0) or (sum(a) ==0):
        print("Yes")
        sys.exit()
if (lsls[0][0]+lsls[0][4]+lsls[0][8] == 0) or (lsls[0][2]+lsls[0][4]+lsls[0][6] == 0):
    print("Yes")
    sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys
L = list(list(map(int,input().split())) for i in range(3))
n = int(input())
ls = [int(input()) for j in range(n)]
lsls = [0]
lsls[0] = L[0] + L[1] + L[2]
for k in range(n):
    for l in range(9):
        if ls[k] == lsls[0][l]:
            lsls[0][l] = 0
for r in range(3):
    a = [e for e in lsls[0] if lsls[0].index(e) % 3 == r]
    if (sum(L[r]) ==0) or (sum(a) ==0):
        print("Yes")
        sys.exit()
if (lsls[0][0]+lsls[0][4]+lsls[0][8] == 0) or (lsls[0][2]+lsls[0][4]+lsls[0][6] == 0):
    print("Yes")
    sys.exit()
print("No")