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: Runtime Error

Solution code:
a1=input().split()
a2=input().split()
a3=input().split()
A=[a1,a2,a3]
b=int(input()) for i in range(int(input()))
if a1[0] and a1[1] and a1[2] in b:
    print("Yes")
elif a2[0] and a2[1] and a2[2] in b:
    print("Yes")
elif a3[0] and a3[1] and a3[2] in b:
    print("Yes")
elif a1[0] and a2[0] and a3[0] in b:
    print("Yes")
elif a1[1] and a2[1] and a3[1] in b:
    print("Yes")
elif a1[2] and a2[2] and a3[2] in b:
    print("Yes")
elif a1[0] and a2[1] and a3[2] in b:
    print("Yes")
elif a1[2] and a2[1] and a3[0] in b:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
def main():
  A = []
  for i in range(3):
    l = list(map(int, input().split()))
    A.append(l)
  A = np.array(A)

  N_list = []
  N = int(input())
  for i in range(N):
    N_list.append(int(input()))
  
  for i in N_list:
    for j in range(3):
      for k in range(3):
        if A[j][k] == i:
          A[j][k] = 0
        else:
          pass
        
  for i in range(3):
    if sum(A[i]) == 0:
      print('Yes')
      exit()
    else:
      pass

  for i in range(3):
    if A.sum(axis=i) == 0:
      print('Yes')
      exit()

  naname1 = A[0][0] + A[1][1] + A[2][2]
  if naname1 == 0:
    print('Yes')
    exit()
  else:
    pass

  naname2 = A[0][2] + A[1][1] + A[2][0]
  if naname2 == 0:
    print('Yes')
    exit()
  else:
    pass

  print('No')

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
A=[]
B=np.zeros(9)
C=[]
for i in range(3):
  A+=map(int,input().split())
N=int(input())
#print(A)
for i in range(N):
  C.append(int(input()))
for i in C:
  if (i in A)==1:
    B[A.index(i)]=1
    A[index(i)]=9999
    if (i in A)==1:
    B[A.index(i)]=1
    
#print(B)
abc=0
for i in range(3):
  if B[0+i*3]==B[1+i*3]==B[2+i*3]==1:
    abc=1

for i in range(3):
  if B[0+i]==B[3+i]==B[6+i]==1:
    abc+1
if B[0]==B[4]==B[8]==1:
  abc=1
if B[2]==B[4]==B[6]==1:
  abc=1
if abc==0:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
[a11, a12, a13],[a21, a22, a23],[a31, a32, a33] = [input().split() for l in range(3)]

if : a == [a11, a12, a13]
    print(Yes)
elif :is [a11, a22, a33]
    print(Yes)
elif :is [a11, a21, a31]
    print(Yes)
elif :is [a12, a22, a32]
    print(Yes)
elif :is [a13, a23, a33]
    print(Yes)
elif :is [a13, a22, a31]
    print(Yes)
elif :is [a21, a22, a23]
    print(Yes)
elif :is [a31, a32, a33]
    print(Yes)
else:
    print(No)

Submission status: Runtime Error

Solution code:
# coding:utf-8

A1=[int(i) for i in input().split()]
A2=[int(i) for i in input().split()]
A3=[int(i) for i in input().split()]
A=[[0,0,0],[0,0,0],[0,0,0]]
N=int(input())
b=[int(input()) for i in range(N)]

for i in b:
    for a in A1:
        if a==i:
            A[0][A1.index(a)]=1
    for a in A2:
        if a==i:
            A[1][A2.index(a)]=1
    for a in A3:
        if a==i:
            A[2][A3.index(a)]=1
if sum(A[0])==3 or sum(A[1])==3 or sum(A[2])==3
    or sum(A[0][0],A[1][0],A[2][0]) or sum(A[0][1],A[1][1],A[2][1]) or sum(A[0][2],A[1][2],A[2][2])
    or sum(A[0][0],A[1][1],A[2][2]) or sum(A[0][2],A[1][1],A[2][0]):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a = []
b = []
for i in range(3):
    ai = list(map(int, input().split()))
    a.append(ai)
n = int(input())
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] == 0 and a[i][1] == 0 and a[i][2] == 0:
        print("Yes")
        break
else:
    for i in range(3):
        if a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
            print("Yes")
            break
    else:
        if c[0][0] == 0 and c[1][1] == 0 and c[2][2] == 0:
            print("Yes")
        elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
            print("Yes")
        else:
            print("No")

Submission status: Runtime Error

Solution code:
import random
import numpy as np
bingo = list(range(1,100))

bingo_card = np.array[[A11,A12,A13],[A21,A22,A23], [A31,A32,A33]]

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
a = [input().split() for i in range(3)]
n = int(input())
b = [input().split() for i in range(n)]
x = list(itertools.chain.from_iterable(a))

list1 = [x[0], x[1], x[2]]
list2 = [x[0], x[3], x[6]]
list3 = [x[0], x[4], x[8]]
list4 = [x[1], x[4], x[7]]
list5 = [x[2], x[5], x[8]]
list6 = [x[2], x[4], x[6]]
list7 = [x[3], x[4], x[5]]
list8 = [x[6], x[7], x[8]]

b1 = np.array(b)
x1 = list(itertools.chain.from_iterable(b1))
count = 0

for z in range(8):
    l1 = np.array("list" + "{z}")

    for e1 in l1:
        if any(e1 in e2 for e2 in x1):
            count += 1
        else:
            count = count
if (count == 3):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A11,A12,A13,A21,A22,A23,A31,A32,A33 = map(int,input().split(" "))
bingo = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
bingo = ",".join(map(str,bingo))
N = int(input())
for i in range(N):
    b = input()
    if b in bingo:
        bingo.replace(b,True)
    else:
        pass
Bingo = bingo.split(",")
Flag = False
if Bingo[0] == Bingo[1] == Bingo[2]:
    Flag = True
if Bingo[3] == Bingo[4] == Bingo[6]:
    Flag = True
if Bingo[6] == Bingo[7] == Bingo[8]:
    Flag = True
if Bingo[0] == Bingo[3] == Bingo[6]:
    Flag = True
if Bingo[1] == Bingo[4] == Bingo[7]:
    Flag = True
if Bingo[2] == Bingo[5] == Bingo[8]:
    Flag = True
if Bingo[0] == Bingo[4] == Bingo[8]:
    Flag = True
if Bingo[2] == Bingo[4] == Bingo[6]:
    Flag = True
else:
    pass
if flag == True:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N=int(input())
    
number=[]
for i in range(N):
    number.append(i)
flag=False

if (bingo[0][0] in number) and (bingo[0][1] in number) and (bingo[0][2] in number):
    flag=True
elif (bingo[1][0] in number) and (bingo[1][1] in number) and (bingo[1][2] in number):
    flag=True
elif (bingo[2][0] in number) and (bingo[2][1] in number) and (bingo[2][2] in number):
    flag=True
elif (bingo[1][1] in number) and (bingo[2][2] in number) and(bingo[0][0] in number):
    flag=True
elif (bingo[0][1] in number)and(bingo[0][2] in number)and(bingo[0][0] in number):
    flag=True
elif (bingo[1][0] in number)and(bingo[1][1] in number)and(bingo[1][2] in number):
    flag=True
elif (bingo[2][0] in number)and(bingo[2][1] in number)and(bingo[2][2] in number):
    flag=True
else:
    pass

if flag==True:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

def check_bingo(bingo_card):
    bingo_cnt = 0
    bingo_list = [[0, 1, 2],
                  [3, 4, 5],
                  [6, 7, 8],
                  [0, 3, 6],
                  [1, 4, 5],
                  [2, 5, 8],
                  [0, 4, 8],
                  [2, 4, 6],]    

    for i in range(len(bingo_list)):
        for j in range(len(bingo_list[i])):
            if bingo_card[bingo_list[i][j]] == 0:
                bingo_cnt +=1
            else:
                break
        
        if bingo_cnt == 3:
            return(True)
            break
        else:
            bingo_cnt = 0
            return(False)

def main():
    bingo_card = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
    cnt = 0
    for i in range(N):
        if b[i] in bingo_card:
            bingo_card[i] = 0
            cnt += 1
        else:
            pass

    if cnt <= 2:
        print('No')                
        
    elif 3 <= cnt <= 6:
        judge_bingo = check_bingo(bingo_card)
        if judge_bingo == True:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')                
    
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
a = [input().split() for i in range(3)]
n = int(input())
b = [input().split() for i in range(n)]
x = list(itertools.chain.from_iterable(a))

list1 = [x[0], x[1], x[2]]
list2 = [x[0], x[3], x[6]]
list3 = [x[0], x[4], x[8]]
list4 = [x[1], x[4], x[7]]
list5 = [x[2], x[5], x[8]]
list6 = [x[2], x[4], x[6]]
list7 = [x[3], x[4], x[5]]
list8 = [x[6], x[7], x[8]]

b1 = np.array(b)
x1 = list(itertools.chain.from_iterable(b1))
count = 0

for z in range(8):
    l1 = np.array("list" + z)

    for e1 in l1:
        if any(e1 in e2 for e2 in x1):
            count += 1
        else:
            count = count
if (count == 3):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
Bingo_index=[]
master =[]
# 二次元リスト
Row = 3
List=[[int(j) for j in input().split()] for i in range(Row)]
# 二次元リストを一次元リストに
dim_List=list(itertools.chain.from_iterable(List))
# print(dim_List)
# ビンゴ表作成終わり

n = int(input())
# print(n)
Num=[int(input()) for i in range(n)]
# print(Num)
# print(set(dim_List) & set(Num))
# 入力処理ここまで

Common = list(set(dim_List) & set(Num))
# print(Common)
# https://teratail.com/questions/156336
# リストに要素をコピーする方法↑
for a in Common:
    # if(my_index(dim_List,a) == False):
    #     print('No')
    Bingo_index.append(dim_List.index(a))
#
# print('Bingo_indexは')
# print(Bingo_index)
# print(sorted(Bingo_index))
if len(Bingo_index) == 0:
     print('No')
     exit()
    # Bingo_indexにビンゴしてるdim_Listの要素のインデックスが入ってる
answer1 = len(list(set([0, 1, 2])&set(Bingo_index)))
answer2 = len(list(set([3, 4, 5])&set(Bingo_index)))
answer3 = len(list(set([6, 7, 8])&set(Bingo_index)))
answer4 = len(list(set([0, 4, 8])&set(Bingo_index)))
answer5 = len(list(set([0, 3, 6])&set(Bingo_index)))
answer6 = len(list(set([1, 4, 7])&set(Bingo_index)))
answer7 = len(list(set([2, 5, 8])&set(Bingo_index)))

# Bingo_indexの中身にとanswer1~7の組み合わせがあるかどうか調べる
# 全部のアンサーとandをとってどれかの長さが3の奴があればyes出力や
master.append(answer1)
master.append(answer2)
master.append(answer3)
master.append(answer4)
master.append(answer5)
master.append(answer6)
master.append(answer7)
# print(master)
# print(master.count('3'))
for e in master:
    if e ==3:
        print('Yes')
        exit()
print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

#print("bingo",bingo)

score = [[0,0,0],[0,0,0],[0,0,0]]
total = 0

Input = []
while True:
    try:
        i = list(map(int, input().split()))
        Input += i
    except EOFError:
        break
        
#print("Input",Input)
for select in Input:
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == select:
                score[i][j] = 1
    #print("score", score)
    for i in range(3):
        total += sum(score[i]) == 3
        total += sum(score[:][i]) == 3

    if (score[0][0] + score[1][1] + score[2][2]) == 3:
        total +=1
    if (score[0][2] + score[1][1] + score[2][0]) == 3:
        total +=1
    #print("total",total)


if total == 0:
  print('No')
elif total > 0
  print('Yes')

Submission status: Runtime Error

Solution code:
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    pritn('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
c=[]
w=0
for i in range(3):
    c.append(list(map(int,input().split())))
N=int(input())
d=[]
for y in range(N):
    d.append(int(input()))
for n in d:
    for p in c:
        for j in p:
            if n in j:
                j=0
for t in c:
    for h in t:
        if c.count(0)==3:
            o=1
            break
    else:
        continue
    break
for v in range(3):
    w=0
    for k in c:
        if k[v]==0:
            w+=1
        if w==3:
            o=1
w=0
for ji in range(3):
    if c[ji][ji]==0:
        w+=1
    if w==3:
        o=1
w=0
for ji2 in range(3):
    if c[ji2][3-ji2]==0:
        w+=1
    if w==3:
        o=1
for v1 in range(3):
    w=0
    for k in range(3):
        if c[k][v1]==0:
            w+=1
        if w==3:
            o=1

if o==1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
f = np.zeros((3, 3))
b = np.zeros((3, 3))
f[0]=list(map(int,input().split()))
f[1]=list(map(int,input().split()))
f[2]=list(map(int,input().split()))
n= int(input())
for i in range(n):
  c = int(input())
  b=np.where(f == c, 1, b)
  #print(b)
b=np.where(b > 0, 1, 0)
#print(b)
if all(b[0][:]) or all(b[1][:]) or all(b[2][:])\
or all(b[:][0]) or all(b[:][1]) or all(b[:][2])\
or 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: Runtime Error

Solution code:
import numpy as np

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

n = int(input())

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

A = np.isin(A, B)
if 3 in np.sum(A, axis=0) \
        or 3 in np.sum(A, axis=1) \
        or 3 == np.trace(A) \
        or 3 == np.trace(A[::-1]):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            print(val)
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    pritn('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A = [int(input()) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

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

Submission status: Runtime Error

Solution code:

#a.append(list(map(int, input().split())))
#b.append(list(map(int, input().split())))
#c.append(list(map(int, input().split())))
a= list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))


count = int(input())

for num in range(count):
    x = int(input())
    for y in range(3):
        if a[y] == x:
            a[y] = 0
    for y in range(3):
        if b[y] == x:
            b[y] = 0
    for y in range(3):
        if c[y] == x:
            c[y] = 0

#ans = 0
#ans = a[0] * a[1] * a[2]
#ans += b[0] * b[1] * b[2]
#ans += c[0] * c[1] * c[2]
#ans += a[0] * b[0] * c[0]
#ans += a[1] * b[1] * c[1]
#ans += a[2] * b[2] * c[2]

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
# 行列の準備
for i in range(3):
	list = np.array(input().split())
bingo_array = list.reshape(3,3)
# 数の読み込み
N = input()
# 数値の読み込み&比較
for j in range(N):
	b = input()
	for k in list:
		if b == k:
			element_num = bingo_array.index()
			bingo_array[element_num] = "〇"

# ビンゴができているか判定
count_dia = 0
list = []
for i in range(3):
	for j in range(3):
		list.append(array[i,j])
		if i == j:
			if array[i,j] == "〇":
				count_dia = count_dia + 1
if count_dia == 3:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
import sys

bingo = [ list(map(int, input().split())) for _ in range(3) ]
t_or_f = [ [False]*3 for _ in range(3) ]

nums = [ r[i]for i in range(3) for r in bingo ]

n = int(input())
for _ in range(n):
  i = int(input())

  if i in nums:
    for x in range(3):
      for y in range(3):
        if bingo[x][y] == i:
          t_or_f[x][y] = True
          break


is_bingo = False
if t_or_f[0][0] and t_or_f[1][1] and t_or_f[2][2]:
  is_bingo = True
  print('Yes')
elif t_or_f[0][2] and t_or_f[1][1] and t_or_f[2][0]:
  is_bingo = True
  print('Yes')
else:
  for i in range(3):
    if t_or_f[i][i] and t_or_f[i+1][i+1] and t_or_f[i+2][i+2]:
      is_bingo = True
      print('Yes')
      sys.exit()

if not is_bingo: print('No')

Submission status: Runtime Error

Solution code:
A = [int(input()) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

if A[0].count(b) == 3 or A[1].count(b) == 3 or A[2].count(b) == 3 or X[A[0][0],A[1][0],A[2][0]].count(b) == 3 or X[A[0][1],A[1][1],A[2][1]].count(b) == 3 or X[A[0][2],A[1][2],A[2][2]].count(b) == 3 or X[A[0][0],A[1][1],A[2][2]].count(b) == 3 or　X[A[0][2],A[1][1],A[2][0]].count(b) == 3:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

N = int(input())

kekka_l = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == bingo_l[i][j]:
                kekka_l[i][j] = 1
                break

for i in range(3):
    if sum(kekka_l[i]) == 3:
        b_flg = 1
        break

sum = 0

for j in range(3):
    for i in range(3):
        sum += kekka_l[i][j]
        if sum == 3:
            b_flg = 1
            break

if kekka_l[0][0] + kekka_l[1][1] + kekka_l[2][2] == 3:
    b_flg = 1

if kekka_l[0][2] + kekka_l[1][1] + kekka_l[2][0] == 3:
    b_flg = 1

if b_flg == 1:
    print('yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
e,d,f=map(int,input().split())
g,h,i=map(int,input().split())
bingo = [a,b,c,d,e,f,g,h,i]
a_list= []
N = int(input())
for i in range(0,N):
    b = int(input())
    if b in bingo:
        a_list.append(bingo.index(b))
if 0 in a_list:
    if 1 in a_list:
        if 2 in a_list:
            yes = 1
    if 3 in a_list:
        if 6 in a_list:
            yes = 1
    if 4 in a_list:
        if 8 in a_list:
            yes = 1
if 1 in a_list:
    if 4 in a_list:
        if 7 in a_list:
            yes = 1
if 2 in a_list:
    if 4 in a_list:
        if 6 in a_list:
            yes = 1
    if 5 in a_list:
        if 8 in a_list:
            yes = 1
if 3 in a_list:
    if 4 in a_list:
        if 5 in a_list:
            yes = 1
if 6 in a_list:
    if 7 in a_list:
        if 8 in a_list:
            yes = 1
if yes == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
matrix = []
# For user input
for i in range(3):  # A for loop for row entries
    a = []
    for j in range(3):  # A for loop for column entries
        a.append(int(input()))
    matrix.append(a)

# For printing the matrix
# for i in range(3):
#     for j in range(3):
#         print(matrix[i][j], end=" ")
#     print()

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

if matrix[0][0] in b:
    if matrix[1][1] in b:
        if matrix[2][2] in b:
            print("Yes")
else: print("No")

Submission status: Runtime Error

Solution code:
a1, a2, a3 = int(input().split())
b1, b2, b3 = int(input().split())
c1, c2, c3 = int(input().split())
bingo = []

limit = int(input())

for _ in range(0, limit):
    n = int(input())
    bingo.append(n)

r = False
c = False
d = False

if (a1 in bingo) and (a2 in bingo) and (a3 in bingo):
    r = True
    pass
elif (b1 in bingo) and (b2 in bingo) and (b3 in bingo):
    r = True
    pass
elif (c1 in bingo) and (c2 in bingo) and (c3 in bingo):
    r = True
    pass

if (a1 in bingo) and (b1 in bingo) and (c1 in bingo):
    c = True
    pass
elif (a2 in bingo) and (b2 in bingo) and (c2 in bingo)::
    c = True
    pass
elif (a3 in bingo) and (b3 in bingo) and (c3 in bingo)::
    c = True
    pass

if (a1 in bingo) and (b2 in bingo) and (c3 in bingo):
    d = True
    pass
elif (a3 in bingo) and (b2 in bingo) and (c1 in bingo):
    d = True
    pass

if (r or c or d) is True:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a=list(map(int,input().split()))
b=len(a)
c=[a]
w=0
for i in range(b-1):
    c.append(list(map(int,input().split())))
N=int(input())
d=[]
for y in range(N):
    d.append(int(input()))
for n in d:
    for p in c:
        for j in p:
            if n in j:
                j=0
for t in c:
    for h in t:
        if c.count(0)==b:
            o=1
            break
    else:
        continue
    break
for v in range(b):
    w=0
    for k in c:
        if k[v]==0:
            w+=1
        if w==b:
            o=1
w=0
for ji in range(b):
    if c[ji][ji]==0:
        w+=1
    if w==b:
        o=1
w=0
for ji2 in range(b):
    if c[ji2][b-ji2]==0:
        w+=1
    if w==b:
        o=1
for v1 in range(b):
    w=0
    for k in range(b):
        if c[k][v1]==0:
            w+=1
        if w==b:
            o=1

if o==1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
c = "check"
for i in range(n):
    v = int(input())
    ind = 0
    if v in a1 :
        ind = a1.index(v)
        a1[ind] = c
    if v in a2 :
        ind = a2.index(v)
        a2[ind] = c
    if v in a3 :
        ind = a3.index(v)
        a3[ind] = c

if ((a1[0] == c and a2[0] == c and a3[0] == c) or  
    (a1[1] == c and a2[1] == c and a3[1] == c) or 
    (a1[2] == c and a2[2] == c and a3[2] == c) or 
    (a1[0] == c and a2[1] == c and a3[2] == c) or
    (a1[2] == c and a2[1] == c and a3[3] == c) or
    a1.count(c) == 3 or
    a2.count(c) == 3 or
    a3.count(c) == 3):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

import sys

DEBUG = False

def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return

def printbingo(bingo):
    if not DEBUG:
        return
    for y in range(0, 3):
        for x in range(0, 3):
            print(bingo[y][x], end=" ")
        print()


def main():
    bingo = [[]] * 3
    bingo[0] = read_int_list()
    bingo[1] = read_int_list()
    bingo[2] = read_int_list()
    locs = {}
    for y in range(0, 3):
        for x in range(0, 3):
            locs[bingo[y][x]] = (y, x)
    printbingo(bingo)
            
    n = read_int()
    for _ in range(0, n):
        b = read_int()
        if b in locs:
            bingo[locs[b][0]][locs[b][1]] = -1
    printbingo(bingo)
    
    # column check
    for y in range(0, 3):
        is_bingo = True
        for x in range(0, 3):
            if bingo[y][x] != -1:
                is_bingo = False
                break
        if is_bingo:
            print("Yes")
            return
    # row check
    for x in range(0, 3):
        is_bingo = True
        for y in range(0, 3):
            if bingo[y][x] != -1:
                is_bingo = False
                break
        if is_bingo:
            print("Yes")
            return
    # cross check
    for (y, x), (dy, dx) in [((0, 0), (1, 1)), ((0, 2), (1, -1))]:
        is_bingo = True
        while is_bingo and 0 <= y < 3 and 0 <= x < 3:
            dprint(f"(x,y):{(x, y)}, (dx,dy):{(dx,dy)}, bing[y][x]: {bingo[y][x]}")
            if bingo[y][x] != -1:
                is_bingo = False
                break
            y += dy
            x += dx
        if is_bingo:
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#Input
l_A =  [[0 for i in range(3)] for j in range(3)]

def detect_BINGO(l_Atf):
    #print(l_Atf)
    #横
    for i in range(3):
        f_detect = True
        for j in range(3):
            #print(f_detect, l_Atf[i][j])
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            #print("横" + str(i))
            return True
    #縦
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[j][i]
        if(f_detect):
            #print("縦" + str(i))
            return True
    #斜
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        #print("斜＼")
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[3-1-i][3-1-i]
    if(f_detect):
        #print("斜／")
        return True
    
    #BINGOなし
    return False

#Process
l_Atf = [[False for i in range(3)] for j in range(3)]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if(l_A[j][k] == b):
                l_Atf[j][k] = True
    #print(l_Atf)

#   print(l_Atf)
f_bingo = detect_BINGO(l_Atf)

#Output
if(f_bingo):
    print("Yes")
else:
    print("no")

Submission status: Runtime Error

Solution code:
first_row = list(map(int, input().split()))
second_row = list(map(int, input().split()))
third_row = list(map(int, input().split()))
card = [first_row, second_row, third_row]
a1, a2, a3 = card[0]
b1, b2, b3 = card[1]
c1, c2, c3 = card[2]
bingo = []

limit = int(input())

for _ in range(0, limit):
    n = int(input())
    bingo.append(n)

r = False
c = False
d = False

if (a1 in bingo) and (a2 in bingo) and (a3 in bingo):
    r = True
    pass
elif (b1 in bingo) and (b2 in bingo) and (b3 in bingo):
    r = True
    pass
elif (c1 in bingo) and (c2 in bingo) and (c3 in bingo):
    r = True
    pass

if (a1 in bingo) and (b1 in bingo) and (c1 in bingo):
    c = True
    pass
elif (a2 in bingo) and (b2 in bingo) and (c2 in bingo)::
    c = True
    pass
elif (a3 in bingo) and (b3 in bingo) and (c3 in bingo)::
    c = True
    pass

if (a1 in bingo) and (b2 in bingo) and (c3 in bingo):
    d = True
    pass
elif (a3 in bingo) and (b2 in bingo) and (c1 in bingo):
    d = True
    pass

if (r or c or d) is True:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import numpy as np

xy = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
num = [list(map(int, input().split())) for _ in range(n)]

def input_b(xy:list, num:int, result:list):
    for i in range(3):
        if num in xy[i]:
            for j in range(3):
                if num==xy[i][j]:
                    result[i][j]=1
    return result
  
def check_result(result:list):

    # 縦判定
    for i in range(3):
        if 3 == np.array(result[0]).sum():
            return "Yes" 

    if 3 in np.array(result[0]) + np.array(result[1]) + np.array(result[2]):
        return "Yes"

    if 3 == result[0][0] + result[1][1] + result[2][2]:
        return"Yes"
    
    return "No"

for i in num:
    result=input_b(xy,i[0],result)

print(check_result(result))

Submission status: Runtime Error

Solution code:
import numpy as np
x = input()
y = input()
z = input()
xa = x.split(" ")
ya = y.split(" ")
za = z.split(" ")
A = np.array([xa,ya,za])
N = int(input())
b =[]
C = np.array([["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"]])
for i in range(1,N+1):
    b.append(input())
for m in range(0,3):
    for n in range(0,3):
        if A[m, n] in b:
            C[m,n] = "Maru"
tate = np.count_nonzero(C == 'Maru', axis=0)

yoko = np.count_nonzero(C == 'Maru', axis=1)

if 3 in tate or 3 in yoko:
    print('Yes')
elif C[0,0] == "Maru" and C[1,1] == "Maru" and C[2,2] == "Maru":
    print("Yes")
elif C[0,2] == "Maru" and C[1,1] == "Maru" and C[2,0] == "Maru":
    print("Yes")
else:
    print("No")