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:
import sys
bingo_size = 3
a = []
an = set()
for _ in range(3):
  a.append(list(map(int, input().split())))
  for i in a[_]:
    an.add(i)

n = int(input())
b = set()
for _ in range(n):
  bi = int(input())
  if bi in an:
    b.add(bi)

for hi in range(3):
  ok = True
  for _ in range(3):
    if a[hi][_] not in b:
      ok = False
      break
    if ok:
      print("Yes")
      sys.exit()

for wi in range(3):
  ok = True
  for _ in range(3):
    if a[_][wi] not in b:
      ok = False
      break
  if ok:
    print("Yes")
    sys.exit()

if all([a[0][0] in b, a[1][1] in b, a[2][2] in b]) or all([a[0][2] in b, a[1][1] in b, a[2][0] in b]):
           print("Yes")
           sys.exit()
           
print("No")

Submission status: Wrong Answer

Solution code:
def resolve():
    A = []
    ans = "No"
    for i in range(3):
        A.append(list(map(int, input().split())))
    n = int(input())
    b = 0
    for j in range(n):
        b = int(input())
        for p in range(3):
            for q in range(3):
                if A[p][q] == b:
                    A[p][q] = 0
    for g in range(3):
        if A[g][g]+A[g][1]+A[g][2] == 0 or A[0][g]+A[1][g]+A[2][g] == 0 or A[0][0]+A[1][1]+A[2][2] == 0 or A[0][2]+A[1][1]+A[2][0] == 0:
             ans ="Yes"
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
a11,a12,a13 = input().split()
a21,a22,a23 = input().split()
a31,a32,a33 = input().split()

n = int(input())
b = list()
i = 0

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


if a11 in b:
    a11 = 'T'

if a12 in b:
    a12 = 'T'

if a13 in b:
    a13 = 'T'

if a21 in b:
    a21 = 'T'

if a22 in b:
    a22 = 'T'

if a23 in b:
    a23 = 'T'

if a31 in b:
    a31 = 'T'

if a32 in b:
    a32 = 'T'

if a33 in b:
    a33 = 'T'

if a11 == 'T':
    if a12 == 'T':
        if a13 == 'T':
            print('Yes')
            exit()
    
    if a22 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()
    
    if a21 == 'T':
        if a31 == 'T':
            print('Yes')
            exit()

elif a12 == 'T':
    if a22 == 'T':
        if a32 == 'T':
            print('Yes')
            exit()

elif a13 == 'T':
    if a22 == 'T':
        if a31 == 'T':
            print('Yes')
            exit()

    if a23 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()

elif a21 == 'T':
    if a22 == 'T':
        if a23 == 'T':
            print('Yes')
            exit()

elif a31 == 'T':
    if a32 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()

else:
    print('No')

Submission status: Wrong Answer

Solution code:
def IsBingo(arr_9):
    BINGO=['x','x','x']
    C1=arr_9[0::2]
    C2=arr_9[1::2]
    C3=arr_9[2::2]
    X1=[arr_9[0],arr_9[4],arr_9[8]]
    X2=[arr_9[2],arr_9[4],arr_9[6]]
    if arr_9[:3]==BINGO or arr_9[3:6]==BINGO or arr_9[6:]==BINGO or C1==BINGO or C2==BINGO or C3==BINGO or X1==BINGO or X2==BINGO:
        return 'BINGO'


A1=list(input().split())
A2=list(input().split())
A3=list(input().split())
A=A1+A2+A3
N=int(input())
for _ in range(N):
    n=input()
    if A.count(n)==1:
        A[A.index(n)]="x"
# A1=A[:3]
# A2=A[3:6]
# A3=A[6:]
# print(A1,A2,A3)

if IsBingo(A)=='BINGO':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().split())) for i in range(3)]
AB=[[0 for i in range(3)] for j in range(3)]
N=int(input())
for i in range(N):
    x=int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k]==x:
                AB[j][k]=1
c=1
for i in range(3):
    if AB[i][0]*AB[i][1]*AB[i][2]==1:
        c=0
        print("Yes")
        break
    if AB[0][i]*AB[1][i]*AB[2][i]==1:
        c=0
        print("Yes")
        break
    if AB[0][0]*AB[1][1]*AB[2][2]==1:
        c=0
        print("Yes")
        break
    if AB[0][2]*AB[1][1]*AB[2][0]==1:
        c=0
        print("Yes")
        

if c==1:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

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

    N = int(input())
    s = [False for _ in range(9)]
    for i in range(N):
        b = int(input())
        if b in A:
            s[A.index(b)] = True

    bingo = \
        (s[0] and s[1] and s[2]) or \
        (s[3] and s[4] and s[5]) or \
        (s[6] and s[7] and s[8]) or \
        (s[0] and s[3] and s[6]) or \
        (s[1] and s[4] and s[7]) or \
        (s[2] and s[5] and s[8]) or \
        (s[0] and s[4] and s[8])

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


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

bingo = [0 for _ in range(9)]
N = int(input())

for i in range(N):
    b = int(input())
    for j in range(9):
        if b == A[j]:
            bingo[j] = 1

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

if sum(bingo[0::4]) == 3:
    f = 1
if sum(bingo[2:7:2]) == 3:
    f = 1

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

'''
1 2 3
4 5 6 
7 8 9
3
1
4
7
'''

Submission status: Wrong Answer

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

bingo = [0 for _ in range(9)]
N = int(input())

for i in range(N):
    b = int(input())
    for j in range(9):
        if b == A[j]:
            bingo[j] = 1

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

if sum(bingo[0::4]) == 3:
    f = 1
elif sum(bingo[2:7:2]) == 3:
    f = 1

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

readline = sys.stdin.buffer.readline
a = np.array([])
for _ in range(3):
  a = np.append(a,list(map(int, readline().split())))
n = int(readline())

a = a.reshape(3,3)
a_2 = np.append(a,np.diag(a))
a_2 = np.append(a_2,[a[0][2],a[1][1],a[2][0]])

a_2 = a_2.reshape(5,3)
for _ in range(n):
  a_2[a_2==int(readline())]=0

print('Yes' if 0 in np.sum(a_2, axis=1) else 'No')

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A = [na() for _ in range(3)]
n = ni()
b = [ni() for _ in range(n)]
bing = [["x"]*3 for i in range(3)]
for i in range(n):
  for j in range(3):
    if b[i] == A[0][j]:
      bing[0][j] = "o"
  for j in range(3):
    if b[i] == A[1][j]:
      bing[1][j] = "o"
  for j in range(3):
    if b[i] == A[2][j]:
      bing[2][j] = "o" 

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

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A = [na() for _ in range(3)]
n = ni()
b = [ni() for _ in range(n)]
bing = [["x"]*3 for i in range(3)]
for i in range(n):
  for j in range(3):
    if b[i] == A[0][j]:
      bing[0][j] = "o"
  for j in range(3):
    if b[i] == A[1][j]:
      bing[1][j] = "o"
  for j in range(3):
    if b[i] == A[2][j]:
      bing[2][j] = "o" 

for i in range(3):
  if bing[i] == ["o","o","o"] or (bing[0][i] == "o" and bing[1][i] == "o" and bing[2][i] == "o"):
    print("Yes")
if (bing[0][0] == "o" and bing[1][1] == "o" and bing[2][2] == "o") or(bing[0][2] == "o" and bing[1][1] == "o" and bing[2][0] == "o"):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A = [na() for _ in range(3)]
n = ni()
b = [ni() for _ in range(n)]
bing = [["x"]*3 for i in range(3)]
for i in range(n):
  for j in range(3):
    if b[i] == A[0][j]:
      bing[0][j] = "o"
  for j in range(3):
    if b[i] == A[1][j]:
      bing[1][j] = "o"
  for j in range(3):
    if b[i] == A[2][j]:
      bing[2][j] = "o"

for i in range(3):
  if bing[i] == ["o","o","o"] or (bing[0][i] == "o" and bing[1][i] == "o" and bing[2][i] == "o"):
    print("y")
if (bing[0][0] == "o" and bing[1][1] == "o" and bing[2][2] == "o") or(bing[0][2] == "o" and bing[1][1] == "o" and bing[2][0] == "o"):
  print("y")
else:
  print("n")

Submission status: Wrong Answer

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    
    a = [[0]*3 for i in range(3)]
    for i in range(3):
        a[i] = list(map(int, input().split()))
    n = int(input())
    b = [0]*n
    bingo = "No"
    for i in range(n):
        b[i] = int(input())
        for k in range(3):
            if a[k][0] == b[i]:
                a[k][0] = 0
            if a[k][1] == b[i]:
                a[k][1] = 0
            if a[k][2] == b[i]:
                a[k][2] = 0
    for i in range(3):
        if a[i][0]+a[i][1]+a[i][2] == 0:
            bingo = "Yes"
    for i in range(3):
        if a[0][i]+a[1][i]+a[2][i] == 0:
            bingo = "Yes"
    if a[0][0]+a[1][1]+a[2][2] == 0:
        bingo = "Yes"
    if a[2][0]+a[1][1]+a[0][2] == 0:
        bingo = "Yes"
     
    print(bingo)

Submission status: Wrong Answer

Solution code:
A = []
ans = 'No'
for i in range(3):
    A.append(list(map(int,input().split())))
n = int(input())
b = 0
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0
for i in range(3):
    if A[i][0]+A[i][1]+A[i][2] == 0 or A[0][i]+A[1][i]+A[2][i] == 0 or A[0][0]+A[1][1]+A[2][2] == 0 or A[2][2]+A[1][1]+ A[0][0] == 0:
            ans ='Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
num_of_number = int(input())

numbers = []

for _ in range(num_of_number):
    numbers.append(int(input()))

for number in numbers:
    for i, A in enumerate(A1):
        if A in numbers:
            A1[i] = -1

    for i, A in enumerate(A2):
        if A in numbers:
            A2[i] = -1

    for i, A in enumerate(A3):
        if A in numbers:
            A3[i] = -1

# 横の確認
if A1.count(-1) == 3 or A2.count(-1) == 3 or A3.count(-1) == 3:
    print('Yes')
    exit()

# 縦の確認
V1_count = [A1[0], A2[0], A3[0]].count(-1)
V2_count = [A1[1], A2[1], A3[1]].count(-1)
V3_count = [A1[2], A2[2], A3[2]].count(-1)
if V1_count == 3 or V2_count == 3 or V2_count == 3:
    print('Yes')
    exit()

# 斜めの確認
D1_count = [A1[0], A2[1], A3[2]].count(-1)
D2_count = [A1[2], A2[1], A3[0]].count(-1)
if D1_count == 3 or D2_count == 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = [[0]*3]*3
for i in range(3):
  a[i] = list(map(int,input().split()))
  
  
def isInList(b,a):
  for i in range(len(a)):
    for j in range(len(a[i])):
      if a[i][j] == b:
        return i,j
      
  return 0,0
  
N = int(input())
for i in range(N):
  b = int(input())
  I,J = isInList(b,a)
  if I != 0:
    a[I][J] = -1
    
def judge(a):
  for i in range(3):
    if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
      return True
  for i in range(3):
    if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
      return True
  tmp = [a[i][i] for i in range(3)]
  if tmp == [-1,-1,-1]:
    return True
  tmp = [a[i][2-i] for i in range(3)]
  if tmp == [-1,-1,-1]:
    return True
  return False


ans = "Yes" if judge(a) else "No"
print(ans)

Submission status: Wrong Answer

Solution code:
a = []
for x in range(3):
    a.append(list(map(int, input().split())))
row = [0] * 3
col = [0] * 3
sli = [0] * 2

n = int(input())
for _ in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b:
                row[x] += 1
                col[y] += 1
                if x == y:
                    sli[0] += 1
                elif x + y == 2:
                    sli[1] += 1

flag = False
for x in row:
    if x == 3:
        flag = True
for x in col:
    if x == 3:
        flag = True
for x in sli:
    if x == 3:
        flag = True
print("Yes" if flag else "No")

Submission status: Wrong Answer

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

bingo = 0
checker = 0

for i in range(len(b)):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = "o"
        checker += 1

if checker > 0:       
  for l in range(3):
    if a[l].count("o") == 3:
      bingo += 1
    if a[l][0] == a[l][1] == a[l][2] == "o":
      bingo += 1
  if a[0][0] == a[1][1] == a[2][2] == "o":
    bingo += 1
  if a[0][2] == a[1][1] == a[2][0] == "o":
    bingo += 1
    
if bingo > 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())
b = [int(input()) for i in range(n)]
set(b)

bingo = 0

for i in range(len(b)):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = "o"     

for l in range(3):
  if a[l].count("o") == 3:
    bingo += 1
  if a[l][0] == a[l][1] == a[l][2] == "o":
    bingo += 1
if a[0][0] == a[1][1] == a[2][2] == "o":
  bingo += 1
if a[0][2] == a[1][1] == a[2][0] == "o":
  bingo += 1

if bingo > 0:
  print(bingo, "Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

N = int(input())

for i in range(N):
    n = int(input())
    if n in a:
        a[a.index(n)] = 0
    elif n in b:
        b[b.index(n)] = 0
    elif n in c:
        c[c.index(n)] = 0

if sum(a) == 0 or sum(b) == 0 or sum(c) == 0 or a[0]+ b[1] + c[2] == 0 or a[2] + b[1] + c[0] == 0 :
    print("Yes")
elif a[0] + b[0]+ c[0] ==0 or a[1] + b[1]+ c[1] or a[2] + b[2]+ c[2] :
    print("Yes")
else:print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

N = int(input())

for i in range(N):
    n = int(input())
    if n in a:
        a[a.index(n)] = 0
    elif n in b:
        b[b.index(n)] = 0
    elif n in c:
        c[c.index(n)] = 0

if sum(a) == 0 or sum(b) == 0 or sum(c) == 0 or a[0]+ b[1] + c[2] == 0 or a[2] + b[1] + c[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_i = list([int(input()) for _ in range(N)])
ans = "No"

for bi in b_i:
    for i in range(3):
        for j in range(3):
            if A[i][j] == bi:
                A[i][j] = "hole"

for i in range(3):
    if A[i][0] == "hole":
        if A[i][1] == "hole" and A[i][1] == "hole":
            ans = "Yes"

for i in range(3):
    if A[0][i] == "hole":
        if A[1][i] == "hole" and A[2][i] == "hole":
            ans = "Yes"

if A[0][0] == "hole" and A[1][1] == "hole" and A[2][2] == "hole":
    ans = "Yes"

if A[0][2] == "hole" and A[1][1] == "hole" and A[2][0] == "hole":
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
al = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
ans = 'No'
for i in b:
    for l in range(3):
        if i in al[l]:
            al[l][al[l].index(i)]=0
if al[0][0]+al[1][1]+al[2][2]==0 or al[0][2]+al[1][1]+al[2][0]==0:
    ans = 'Yes'
else:
    for l in al:
        if sum(l)==0:
            ans = 'Yes'
            break
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
b_card = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
nums = [int(input()) for _ in range(N)]

card_st = [[0] *3] * 3

for num in nums:
    for index, card_num in enumerate(b_card):
        if num in card_num:
            card_st[index][card_num.index(num)] = 1

if True in np.all(card_st, axis=0):
    print('Yes')
elif True in np.all(card_st, axis=1):
    print('Yes')
elif np.all(np.diag(card_st) == 1):
    print('Yes')
elif np.all(np.diag(np.fliplr(card_st)) == 1):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

C = []
  
C.append(A[0])
C.append(A[1])
C.append(A[2])
C.append([A[0][0], A[1][0], A[2][0]])
C.append([A[0][1], A[1][1], A[2][1]])
C.append([A[0][2], A[1][2], A[1][2]])
C.append([A[0][0], A[1][1], A[2][2]])
C.append([A[0][2], A[1][1], A[2][0]])

flag = False

for c in C:
  if len(set(c)&set(B)) == 3:
    flag = True
    break
    
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = list([int(input()) for _ in range(n)])
ans = "No"

# ana check
for bi in b:
    print(bi)
    for i in range(3):
        for j in range(3):
            if a[i][j] == bi:
                a[i][j] = "hole"

# tate bingo
for j in range(3):
    if a[0][j] == "hole":
        if a[1][j] == "hole" and a[2][j] == "hole":
            ans = "Yes"

# yoko bingo
for i in range(3):
    if a[i][0] == "hole":
        if a[i][1] == "hole" and a[i][2] == "hole":
            ans = "Yes"

# naname bingo
if a[0][0] == "hole" and a[1][1] == "hole" and a[2][2] == "hole":
    ans = "Yes"
if a[0][2] == "hole" and a[1][1] == "hole" and a[2][0] == "hole":
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = list([int(input()) for _ in range(n)])
ans = "No"

# ana check
for bi in b:
    print(bi)
    for i in range(3):
        for j in range(3):
            if a[i][j] == bi:
                a[i][j] = "hole"

# tate bingo
for j in range(3):
    if a[0][j] == "hole":
        if a[1][j] == "hole" and a[2][j] == "hole":
            ans = "Yes"

# yoko bingo
for i in range(3):
    if a[i][0] == "hole":
        if a[i][1] == "hole" and a[i][2] == "hole":
            ans = "Yes"

# naname bingo
if a[0][0] == "hole" and a[1][1] == "hole" and a[1][1] == "hole":
    ans = "Yes"
if a[0][2] == "hole" and a[1][1] == "hole" and a[2][0] == "hole":
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
a = np.array([ list(map(int, input().split())) for _ in range(3) ])
c = np.array([ [0] * 3 for _ in range(3) ])
n = int(input())
b_l = [ int(input()) for _ in range(n) ]


for i in range(3):
    for j in range(3):
        if a[i][j] in b_l:
            c[i][j] = 1

r = 'No'
# row and column
for i in range(3):
    if sum(c[i]) == 3:
        r = 'Yes'
    if sum(c.T[i]) == 3:
        r = 'Yes'

# cross
if (c[0][0] + c[1][1] + c[2][2]) == 3:
    r = 'Yes'

if (c.T[0][0] + c.T[1][1] + c.T[2][2]) == 3:
    r = 'Yes'
print(r)

Submission status: Wrong Answer

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

N = int(input())

for n in range(N):
    b = int(input())
    flag = False
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                B[i][j] = 1
                flag = True
                break
        if flag:
            break

C = [0]*8
for i in range(3):
    for j in range(3):
        if i == j:
            C[6] += B[i][j]
        if i+j==2:
            C[7] += B[i][j]
        C[i] += B[i][j]
        C[j+2] += B[i][j]

for i in range(8):
    if C[i]==3:
        print('Yes')
        break
    if i == 7:
        print('No')

Submission status: Wrong Answer

Solution code:
a1,a2,a3,_,*b = [i.split() for i in open(0)]
bingo = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [2, 5, 8], [0, 3, 6], [1, 4, 7], [0, 4, 8], [2, 4, 6]]
s = ["" if i in b else i for i in a1 + a2 + a3]
for i,j,k in bingo:
    if {s[i],s[j],s[k]} ==  {''}:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
al = []
ans = 'No'
for i in range(3):
    al.append(list(map(int, input().split())))
n = int(input())
bl = [int(input()) for i in range(n)]
for i in bl:
    for a in al:
        if i in a:
            a[a.index(i)]=0           
t1 = al[0][0]+al[1][1]+al[2][2]
t2 = al[0][2]+al[1][1]+al[2][0]
if t1 ==0 or t2==0:
    ans = 'Yes'
else:
    for a in al:
        if sum(a)==0:
            ans = 'Yes'
            break
        else:
            for va in zip(*al):
                if sum(va)==0:
                    ans = 'Yes'
                    break
print('Yes')

Submission status: Wrong Answer

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

xx = sum(x, [])

tate1 = xx[0:9:3]
tate2 = xx[1:9:3]
tate3 = xx[2:9:3]
yoko1 = xx[0:3]
yoko2 = xx[3:6]
yoko3 = xx[6:9]
nana1 = xx[0:9:4]
nana2 = xx[2:9:2]

if rows >= 3 and (set(tate1) <= set(y) or set(tate2) <= set(y) or set(tate3) <= set(y) or set(yoko1) <= set(y) or set(yoko2) <= set(y) or set(yoko3) <= set(y) or set(nana1) <= set(y) or set(nana2) <= set(y)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

xx = sum(x, [])

tate1 = xx[0:9:3]
tate2 = xx[1:9:3]
tate3 = xx[2:9:3]
yoko1 = xx[0:3]
yoko2 = xx[3:6]
yoko3 = xx[6:9]
nana1 = xx[0:9:4]
nana2 = xx[2:9:2]

if rows >= 3 and set(tate1) <= set(y) or set(tate2) <= set(y) or set(tate3) <= set(y) or set(yoko1) <= set(y) or set(yoko2) <= set(y) or set(yoko3) <= set(y) or set(nana1) <= set(y) or set(nana2) <= set(y):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

xx = sum(x, [])

tate1 = xx[0:9:3]
tate2 = xx[1:9:3]
tate3 = xx[2:9:3]
yoko1 = xx[0:3]
yoko2 = xx[3:6]
yoko3 = xx[6:9]
nana1 = xx[0:9:4]
nana2 = xx[2:9:2]

if set(tate1) <= set(y) or set(tate2) <= set(y) or set(tate3) <= set(y) or set(yoko1) <= set(y) or set(yoko2) <= set(y) or set(yoko3) <= set(y) or set(nana1) <= set(y) or set(nana2) <= set(y):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
matriz=[]
for i in range(3):
	linhas=input()
	sep= linhas.split()
	lint= []
	for x in sep:
		lint.append(int(x))
	matriz.append(lint)

n=int(input())
k=0
l=[]
for i in range(n):
	l.append(int(input()))

for i in range(3):
    for j in range(3):
        if matriz[i][j] in l:
            matriz[i][j]=-1
#linha
if matriz[0][0]==-1 and matriz[0][1]==-1 and matriz[0][2]==-1:
	print("Yes")
elif matriz[1][0]==-1 and matriz[1][1]==-1 and matriz[1][2]==-1:
	print("Yes")
elif matriz[2][0]==-1 and matriz[2][1]==-1 and matriz[2][2]==-1:
	print("Yes")
#coluna
elif matriz[0][0]==-1 and matriz[1][0]==-1 and matriz[2][0]==-1:
	print("Yes")
elif matriz[0][1]==-1 and matriz[1][1]==-1 and matriz[2][1]==-1:
	print("Yes")
elif matriz[0][2]==-1 and matriz[2][1]==-1 and matriz[2][2]==-1:
	print("Yes")
#diagonal
elif matriz[0][0]==-1 and matriz[1][1]==-1 and matriz[2][2]==-1:
	print("Yes")

elif matriz[0][2]==-1 and matriz[1][1]==-1 and matriz[2][0]==-1:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
l=[0]*3
for i in range(3):
    a=list(map(int,input().split()))
    l[i]=a
n=int(input())
bingo=[[1]*3 for _ in range(3)]
b=[]
for i in range(n):
    B=int(input())
    b.append(B)
for i in range(3):
    for j in range(3):
        if l[i][j] in b:
            bingo[i][j]=0
x=0
cnt=0
nana1=0
nana2=0
for i in range(3):
    if sum(bingo[i])==0:
        print("Yes")
        x=1
        break
    cnt+=bingo[i][0]
    nana1+=bingo[i][i]
    nana2+=bingo[i][2-i]
if x==0:
    if cnt==0 or nana1==0 or nana2==0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
l=[0]*3
for i in range(3):
    a=list(map(int,input().split()))
    l[i]=a
n=int(input())
bingo=[[1]*3 for _ in range(3)]
b=[]
for i in range(n):
    B=int(input())
    b.append(B)
for i in range(3):
    for j in range(3):
        if l[i][j] in b:
            bingo[i][j]=0
cnt=0
nana1=0
nana2=0
for i in range(3):
    if sum(bingo[i])==0:
        print("Yes")
        x=1
        exit()
    cnt+=bingo[i][0]
    nana1+=bingo[i][i]
    nana2+=bingo[i][2-i]
if cnt==0 or nana1==0 or nana2==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def resolve():
    A1 = list(map(int, input().split()))
    A2 = list(map(int, input().split()))
    A3 = list(map(int, input().split()))
    N = int(input())
    b = [int(input()) for i in range(N)]

    A = A1 + A2 + A3
    checkA = [0]*9
    for i in range(N):
        if b[i] in A:
            checkA[A.index(b[i])] = 1
    flag = False
    for i in range(3):
        if checkA[i] + checkA[i+1] + checkA[i+2] == 3:
            flag = True
        elif checkA[i] + checkA[i+3] + checkA[i+6] == 3:
            flag = True

    if checkA[0] + checkA[4] + checkA[8] == 3:
        flag = True
    elif checkA[2] + checkA[4] + checkA[6] == 3:
        flag = True
    if flag:
        print('Yes')
    else:
        print('No')
resolve()

Submission status: Wrong Answer

Solution code:
a=[]
for i in range(3):
  aa=list(map(str,input().split()))
  a.append(aa)
  
n=int(input())
ln=[]
for i in range(n):
  lnn=input()
  ln.append(lnn)
  
visited=[[0]*3 for i in range(3)]

for i in range(3):
  for j in range(3):
    for k in range(n):
      if ln[k] in a[i][j]:
        visited[i][j]=1

for j in range(3):
  if visited[0][j]==1 and visited[1][j]==1 and visited[2][j]==1:
    print('Yes')
    exit()
    
for i in range(3):
  if visited[i][0]==1 and visited[i][1]==1 and visited[i][2]==1:
    print('Yes')
    exit()
    
if visited[0][0]==1 and visited[1][1]==1 and visited[2][2]==1:
  print('Yes')
  exit()
  
if visited[0][2]==1 and visited[1][1]==1 and visited[2][0]==1:
  print('Yes')
  exit()
  
print('No')

Submission status: Wrong Answer

Solution code:
A = [[] for _ in range(3)]

A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))

N = int(input())
B = [[False, False, False] 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:
                B[j][k] = True

if all(B[0]) or all(B[1]) or all(B[2]):
    print('Yes')
elif all([B[0][0], B[1][0], B[2][0]]) or all([B[0][1], B[1][1], B[2][1]]) or all([B[2][0], B[2][1], B[2][2]]):
    print('Yes')
elif all([B[0][0], B[1][1], B[2][2]]) or all([B[0][2], B[1][1], B[2][0]]):
    print('Yes')
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a=[]
for i in range(3):
  aa=list(map(str,input().split()))
  a.append(aa)
  
n=int(input())
ln=[]
for i in range(n):
  lnn=input()
  ln.append(lnn)
  
visited=[[0]*3 for i in range(3)]

for i in range(3):
  for j in range(3):
    for k in range(n):
      if ln[k] in a[i][j]:
        visited[i][j]=1

for j in range(3):
  if all([visited[i][j] for i in range(3)])==1:
    print('Yes')
    exit()
    
for i in range(3):
  if all([visited[i][j] for j in range(3)])==1:
    print('Yes')
    exit()
    
if visited[0][0]==1 and visited[1][1]==1 and visited[2][2]==1:
  print('Yes')
  exit()
  
if visited[0][2]==1 and visited[1][1]==1 and visited[2][0]==1:
  print('Yes')
  exit()
  
print('No')

Submission status: Wrong Answer

Solution code:
bingo=[]
karibingo=[]
for i in range(3):
    a=list(map(int,input().split()))
    bingo.append(a)
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k]==b:
                karibingo.append([j,k])
def bingohantei():
    count3 = 0
    for i in range(3):
        count=0
        count2=0
        if [i,i] in karibingo:
            count3+=1
        if count3==3:return True
        for j in range(3):
            if [i,j] in karibingo:
                count+=1
            if [j,i] in karibingo:
                count2+=1
            if count==3 or count2==3:return True
if bingohantei():
    print("Yes")
else:print("No")

Submission status: Wrong Answer

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

for k in range(N):
  for i in range(3):
    for j in range(3):
      if card[i][j] == b[k]:
        card[i][j] = 0
      
print(card)

#bingo = False
for i in range(3):
  if card[i] == [0, 0, 0]:
    #bingo = True
    print("Yes")
    exit()
  elif [x[i] for x in card] == [0, 0, 0]:
    #bingo = True
    print("Yes")
    exit()
    
if [card[i][i] for i in range(3)] == [0, 0, 0]:
  #bingo = True
  print("Yes")
  exit()
elif [card[2-i][i] for i in range(3)] == [0, 0, 0]:
  #bingo = True
  print("Yes")
  exit()
else:
  #print("Yes" if bingo else "No")
  print("No")