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: Accepted

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

def check_bingo(m_l):
    if sum(m_l[0]) == 3:
        return True
    if sum(m_l[1]) == 3:
        return True
    if sum(m_l[2]) == 3:
        return True
    if sum(m_l[:,0]) == 3:
        return True
    if sum(m_l[:,1]) == 3:
        return True
    if sum(m_l[:,2]) == 3:
        return True
    if sum([m_l[0,0],m_l[1,1],m_l[2,2]]  ) == 3:
        return True
    if sum([m_l[0,2],m_l[1,1],m_l[2,0]]  ) == 3:
        return True
    return False

for b in b_l:
    for i,a in enumerate(a_l):
        for j,v in enumerate(a):
            if b == v:
                m_l[i][j]=1
if check_bingo(m_l):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a, b, c = [],[],[]
ans = "No"
num = [[0, 1, 2],[3, 4, 5],[6, 7, 8],[0, 3, 6],[1, 4, 7],[2, 5, 8],[0, 4, 8],[2, 4, 6]]
for _ in range(3):
    n = list(map(int,input().split()))
    for i in range(3):
        a.append(n[i])
        
n = int(input())
for j in range(n):
    b.append(int(input()))
    
for k in range(9):
    for l in b:
        if a[k] == l:
            c.append(int(k))

for m in range(8):
    q = 0
    for p in range(3):
        if num[m][p] in c:
            q += 1
    if q == 3:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
def is_b(l):
    return all([a[i][j] in b for i, j in l])

a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
t = [[(i, j) for j in range(3)] for i in range(3)]
t += [[(j, i) for j in range(3)] for i in range(3)]
t += [[(i, i) for i in range(3)]] + [[(2 - i, i) for i in range(3)]]
print('Yes' if any([is_b(ti) for ti in t]) else 'No')

Submission status: Accepted

Solution code:
import itertools

a = []
for i in range(3):
    aa = list(map(int,input().split()))
    a.append(aa)
a = list(itertools.chain.from_iterable(a))

b = []
n = int(input())
for i in range(n):
    x = int(input())
    if x in a:
        ii = a.index(x)
        b.append(ii)
c = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6]] 
flg = False
for i in range(8):
    ci, cj, ck = c[i][0], c[i][1], c[i][2]
    if ci in b and cj in b and ck in b:
        flg = True
        break
print('Yes') if flg else print('No')

Submission status: Accepted

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

N = int(input())
A10,A11,A12,A20,A21,A22,A30,A31,A32 = 0,0,0,0,0,0,0,0,0
for n in range(N):
  b = int(input())
  
  if A1[0] == b:
    A10 += 1
  elif A1[1] == b:
    A11 += 1
  elif A1[2] == b:
    A12 += 1
  elif A2[0] == b:
    A20 += 1
  elif A2[1] == b:
    A21 += 1
  elif A2[2] == b:
    A22 += 1
  elif A3[0] == b:
    A30 += 1
  elif A3[1] == b:
    A31 += 1
  elif A3[2] == b:
    A32 += 1

if A10+A11+A12 == 3:
  print("Yes")
elif A20+A21+A22 == 3:
  print("Yes")
elif A30+A31+A32 == 3:
  print("Yes")
elif A10+A20+A30 == 3:
  print("Yes")
elif A11+A21+A31 == 3:
  print("Yes")
elif A12+A22+A32 == 3:
  print("Yes")
elif A10+A21+A32 == 3:
  print("Yes")
elif A12+A21+A30 == 3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
ls=[]
for i in range(3):
    ls1=list(map(int,input().split()))
    ls.append(list(ls1))
    ls1.clear()
#print(ls)
N=int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for l in range(3):
            if ls[l][j] == b:
                ls[l][j] = -1
flg = False
for i in range(3):
    if ls[i][0] == ls[i][1] == ls[i][2] == -1:
        print("Yes")
        flg = True
        break
    elif ls[0][i] == ls[1][i] == ls[2][i] == -1:
        print("Yes")
        flg = True
        break
    elif ls[0][0] == ls[1][1] == ls[2][2] == -1:
        print("Yes")
        flg = True
        break
    elif ls[0][2] == ls[1][1] == ls[2][0] == -1:
        print("Yes")
        flg = True
        break
if flg == False:
    print("No")

Submission status: Accepted

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

  
  

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


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

Submission status: Accepted

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

l = [0]*9
n = int(input())

for i in range(n):
    b = int(input())
    for k in range(9):
        if a[k] == b:
            l[k] += 1
 
if l[0] == 1 and l[1] == 1 and l[2] == 1:
    print('Yes')
elif l[3] == 1 and l[4] == 1 and l[5] == 1:
    print('Yes')
elif l[6] == 1 and l[7] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[3] == 1 and l[6] == 1:
    print('Yes')
elif l[1] == 1 and l[4] == 1 and l[7] == 1:
    print('Yes')
elif l[2] == 1 and l[5] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[4] == 1 and l[8] == 1:
    print('Yes')
elif l[2] == 1 and l[4] == 1 and l[6] == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

l = [0]*9
n = int(input())

for i in range(n):
    b = int(input())
    if b in a:
        l[a.index(b)] += 1

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

Submission status: Accepted

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

n=int(input())

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

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

N = int(input())

NP_A = np.array(A)
b = []
for n in range(N):
  b.append(int(input()))

for n in range(N):
  NP_A = np.where(NP_A==b[n], 0, NP_A)

ans = "No"

for i in range(2):
    if 0 in NP_A.sum(axis=i):
        ans = "Yes"
        break

if ans == "Yes":
    pass
else:
    sum = 0
    for i in range(3):
        sum += NP_A[i, i]
    if sum == 0:
        ans = "Yes"
    else:
        sum = NP_A[0, 2] + NP_A[1, 1] + NP_A[2, 0]
        if sum == 0:
            ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
lst = []
for _ in range(N):
    i = int(input())
    lst.append(i)

for n, i in enumerate(A1):
    for j in lst:
        if i == j:
            A1[n] = 0

for n, i in enumerate(A2):
    for j in lst:
        if i == j:
            A2[n] = 0
            
for n, i in enumerate(A3):
    for j in lst:
        if i == j:
            A3[n] = 0
            
B1 = sum(A1)
B2 = sum(A2)
B3 = sum(A3)
B4 = A1[0] + A2[0] + A3[0]
B5 = A1[1] + A2[1] + A3[1]
B6 = A1[2] + A2[2] + A3[2]
B7 = A1[0] + A2[1] + A3[2]
B8 = A1[2] + A2[1] + A3[0]

if B1 * B2 * B3 * B4 * B5 * B6 * B7 * B7 * B8 == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    for i in b:
        A = [[(a if a != i else 0) for a in l] for l in A]

    return [NO, YES][any([not any(l) for l in [*A, *[[A[i][j] for i in range(3)] for j in range(3)], [A[0][0], A[1][1], A[2][2]], [A[2][0], A[1][1], A[0][2]]]])]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(A, N, b)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    for i in b:
        A = [[(a if a != i else 0) for a in l] for l in A]
    return [NO, YES][any([not any(l) for l in A]) or any([not any([A[i][j] for i in range(3)]) for j in range(3)]) or not any([A[0][0], A[1][1], A[2][2]]) or not any([A[2][0], A[1][1], A[0][2]])]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(A, N, b)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    for i in b:
        A = [[(a if a != i else 0) for a in l] for l in A]
    return [NO, YES][any([sum(l) == 0 for l in A]) or any([sum([A[i][j] for i in range(3)]) == 0 for j in range(3)]) or (A[0][0]+A[1][1]+A[2][2] == 0) or (A[2][0]+A[1][1]+A[0][2] == 0)]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(f'{solve(A, N, b)}')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

A = numpy.array([A1, A2, A3])
C = numpy.zeros(A.shape)

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

    C[A == b] = 1

diag1 = numpy.array([C[0,0], C[1,1], C[2,2]])
diag2 = numpy.array([C[0,2], C[1,1], C[2,0]])

flag = False

if numpy.all(C[0] == 1) or numpy.all(C[1] == 1) or numpy.all(C[2] == 1):
    flag = True

if numpy.all(C.T[0] == 1) or numpy.all(C.T[1] == 1) or numpy.all(C.T[2] == 1):
    flag = True

if numpy.all(diag1 == 1) or numpy.all(diag2 == 1):
    flag = True

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

Submission status: Accepted

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

card = [False] * 9
for selection in b:
    for i, a in enumerate(A):
        if selection == a:
            card[i] = True

# judge
answer = 'No'
# row
if (card[0] and card[1] and card[2]) \
or (card[3] and card[4] and card[5]) \
or (card[6] and card[7] and card[8]):
    answer = 'Yes'
# col
if (card[0] and card[3] and card[6]) \
or (card[1] and card[4] and card[7]) \
or (card[2] and card[5] and card[8]):
    answer = 'Yes'
# cross
if (card[0] and card[4] and card[8]) \
or (card[2] and card[4] and card[6]):
    answer = 'Yes'
print(answer)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))
def bingo(a, b, c):
    if a[0] == b[0] == c[0]:
        return True
    if a[1] == b[1] == c[1]:
        return True
    if a[2] == b[2] == c[2]:
        return True
    if a[0] == a[1] == a[2]:
        return True
    if b[0] == b[1] == b[2]:
        return True
    if c[0] == c[1] == c[2]:
        return True
    if a[0] == b[1] == c[2]:
        return True
    if a[2] == b[1] == c[0]:
        return True
    return False

l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n = int(input())
ans = "No"
for i in range(n):
    b = int(input())
    for j in range(3):
        if l1[j] == b:
            l1[j] = 0
        if l2[j] == b:
            l2[j] = 0
        if l3[j] == b:
            l3[j] = 0
    if (bingo(l1,l2,l3)):
         ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
# abc157_b.py
# https://atcoder.jp/contests/abc157/tasks/abc157_b

# B - Bingo /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 3×3のサイズのビンゴカードがあります。上から i 行目、左から j 列目の数は Ai,jです。

# 続けて、 N個の数 b1,b2,⋯,bNが選ばれます。
# 選ばれた数がビンゴカードの中にあった場合、ビンゴカードのその数に印を付けます。
# N個の数字が選ばれた時点でビンゴが達成されているか、則ち、縦・横・斜めのいずれか 1 列に並んだ 3つの数の組であって、
# 全てに印の付いているものが存在するかどうかを判定してください。

# 制約
#     入力は全て整数
#     1≤Ai,j≤100
#     Ai1,j1≠Ai2,j2((i1,j1)≠(i2,j2))
#     1≤N≤10
#     1≤bi≤100
#     bi≠bj(i≠j)

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A1,1 A1,2 A1,3
# A2,1 A2,2 A2,3
# A3,1 A3,2 A3,3
# N
# b1
# ⋮
# bN

# 出力
# ビンゴが達成されているならば Yes と、そうでないならば No と出力せよ。

# 入力例 1
# 84 97 66
# 79 89 11
# 61 59 7
# 7
# 89
# 7
# 87
# 79
# 24
# 84
# 30

# 出力例 1
# Yes

# A1,1,A2,1,A2,2,A3,3に印が付けられます。このとき、左上から右下にかけて斜めに 3個の印が並び、ビンゴが成立しています。

# 入力例 2
# 41 7 46
# 26 89 2
# 78 92 8
# 5
# 6
# 45
# 16
# 57
# 17

# 出力例 2
# No

# 印は 1つも付いていません。

# 入力例 3
# 60 88 34
# 92 41 43
# 65 73 48
# 10
# 60
# 43
# 88
# 11
# 48
# 73
# 65
# 41
# 92
# 34

# 出力例 3
# Yes

# 全てのマスに印が付いています。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[3])
    # N, M = list(map(int, lines[0].split()))
    values_a1 = list(map(int, lines[0].split()))
    values_a2 = list(map(int, lines[1].split()))
    values_a3 = list(map(int, lines[2].split()))
    values = list()
    for i in range(N):
        values.append(int(lines[i+4]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    # ビンゴしているかどうかのフラグs
    flags = [0] * 9

    for n in range(N):
        if values[n] == values_a1[0]:
            flags[0] = 1
        if values[n] == values_a1[1]:
            flags[1] = 1
        if values[n] == values_a1[2]:
            flags[2] = 1
        if values[n] == values_a2[0]:
            flags[3] = 1
        if values[n] == values_a2[1]:
            flags[4] = 1
        if values[n] == values_a2[2]:
            flags[5] = 1
        if values[n] == values_a3[0]:
            flags[6] = 1
        if values[n] == values_a3[1]:
            flags[7] = 1
        if values[n] == values_a3[2]:
            flags[8] = 1

    result = 'No'
    # 横
    if flags[0] * flags[1] * flags[2] == 1:
        result = 'Yes'
    if flags[3] * flags[4] * flags[5] == 1:
        result = 'Yes'
    if flags[6] * flags[7] * flags[8] == 1:
        result = 'Yes'
    # 縦
    if flags[0] * flags[3] * flags[6] == 1:
        result = 'Yes'
    if flags[1] * flags[4] * flags[7] == 1:
        result = 'Yes'
    if flags[2] * flags[5] * flags[8] == 1:
        result = 'Yes'
    # 斜め
    if flags[0] * flags[4] * flags[8] == 1:
        result = 'Yes'
    if flags[2] * flags[4] * flags[6] == 1:
        result = 'Yes'

    return [result]


# 引数を取得
def get_input_lines():
    lines = list()
    for _ in range(3):
        lines.append(input())
    line = input()
    N = int(line)
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['84 97 66', '79 89 11', '61 59 7', '7', '89', '7', '87', '79', '24', '84', '30']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['41 7 46', '26 89 2', '78 92 8', '5', '6', '45', '16', '57', '17']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['60 88 34', '92 41 43', '65 73 48', '10', '60', '43', '88', '11', '48', '73', '65', '41', '92', '34']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

A = [0] * 3
for i in range(3):
  A[i] = list(map(int, input().split()))
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))


for b_i in b:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b_i:
        A[i][j] = 0

if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
  print('Yes')
elif A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0:
  print('Yes')
elif A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0:
  print('Yes')
elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
  print('Yes')
elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
  print('Yes')
elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
  print('Yes')
elif A[0][0] == 0 and A[1][1] == 0 and A[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: Accepted

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

import numpy as np

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

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

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

Submission status: Accepted

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

n=int(input())
for i in range(n):
    b=int(input())
    if b in A:
        A=np.where(A==b,0,A)
cross=0
if A[0][0]+A[1][1]+A[2][2]==0 or A[2][0]+A[1][1]+A[0][2]==0:
    cross=1
print("NYoe s"[0 in np.sum(A,axis=0) or 0 in np.sum(A,axis=1) or cross ::2])

Submission status: Accepted

Solution code:
def bingo():
    # 初期処理
    A = list()
    b = list()
    comb_list = list()
    is_bingo = False
    # 入力
    for _ in range(3):
        dummy = list(map(int, input().split()))
        A.append(dummy)
    N = int(input())
    for _ in range(N):
        dummy = int(input())
        b.append(dummy)
    # ビンゴになる組み合わせ
    for i in range(3):
        # 横
        comb_list.append([A[i][0], A[i][1], A[i][2]])
        # 縦
        comb_list.append([A[0][i], A[1][i], A[2][i]])
    # 斜め
    comb_list.append([A[0][0], A[1][1], A[2][2]])
    comb_list.append([A[0][2], A[1][1], A[2][0]])
    # 集計（出現した数字をnullに置き換え)
    for i in b:
        for j in range(8):
            for k in range(3):
                if i == comb_list[j][k]:
                    comb_list[j][k] = 'null'
    # すべてnullのリストの存否
    for i in comb_list:
        for j in i:
            if 'null' != j:
                is_bingo = False
                break
            else:
                is_bingo = True
        # 一組でもbingoがあれば即座に関数を抜ける
        if is_bingo == True:
            return 'Yes'
    # すべてのリストを確認後
    if is_bingo == False:
        return 'No'
        

result = bingo()
print(result)

Submission status: Accepted

Solution code:
import numpy as np


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

    return 'No'


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def is_bingo(ary):
    flag = False
    for i in range(3):
        if ary[i][0] == "hit" and ary[i][1] == 'hit' and ary[i][2] == 'hit':
            flag = True
            break
        if ary[0][i] == "hit" and ary[1][i] == 'hit' and ary[2][i] == 'hit':
            flag = True
            break
    if ary[0][0] == "hit" and ary[1][1] == 'hit' and ary[2][2] == 'hit':
        flag = True
    if ary[0][2] == "hit" and ary[1][1] == 'hit' and ary[2][0] == 'hit':
        flag = True
    return flag

answer_seets = [[0,0,0] for _ in range(3)]
for i in range(3):
    tmp_lis = list(input().split())
    for idx, tmp in enumerate(tmp_lis):
        answer_seets[i][idx] = tmp
N = int(input())
for _ in range(N):
    b = input()
    for i in range(3):
        for j in range(3):
            if answer_seets[i][j] == b:
                answer_seets[i][j] = "hit"
                break
        else:
            continue
        break

if is_bingo(answer_seets):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from itertools import product


def main():
    input = sys.stdin.buffer.readline
    card = [[0] * 3 for _ in range(3)]
    for i in range(3):
        line = list(map(int, input().split()))
        card[i] = line
    mark = [[0] * 3 for _ in range(3)]
    n = int(input())
    for _ in range(n):
        b = int(input())
        for i, j in product(range(3), repeat=2):
            if card[i][j] == b:
                mark[i][j] = 1
                break

    for i in range(3):
        s = 0
        for j in range(3):
            s += mark[i][j]
        if s == 3:
            print("Yes")
            sys.exit()

    for j in range(3):
        s = 0
        for i in range(3):
            s += mark[i][j]
        if s == 3:
            print("Yes")
            sys.exit()

    s = 0
    for i in range(3):
        s += mark[i][i]
    if s == 3:
        print("Yes")
        sys.exit()

    s = 0
    for i in range(3):
        s += mark[i][2 - i]
    if s == 3:
        print("Yes")
        sys.exit()

    print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A = []
for _ in range(3):
    a = [int(a) for a in input().split()]
    A.append(a)
N = int(input())
for _ in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==num:
                A[i][j] = -1

# Rows
for row in range(3):
    bingo_row = True
    for col in range(3):
        if A[row][col]!=-1:
            bingo_row = False
    if bingo_row:
        print('Yes')
        exit()
    
# Columns
for col in range(3):
    bingo_col = True
    for row in range(3):
        if A[row][col]!=-1:
            bingo_col = False
    if bingo_col:
        print('Yes')
        exit()

# Naname
bingo_naname = True
for i in range(3):
    col, row = i, i
    if A[row][col] != -1:
        bingo_naname = False
if bingo_naname:
    print('Yes')
    exit()
bingo_naname = True
for i in range(3):
    col, row = 2-i, i
    if A[row][col] != -1:
        bingo_naname = False
if bingo_naname:
    print('Yes')
    exit()

print('No')

Submission status: Accepted

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

    for bb in b:
        for i in range(3):
            for j in range(3):
                if bb == A[i][j]:
                    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()

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

    if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
        print('Yes')
        exit()
    if A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
        print('Yes')
        exit()

    print('No')


if __name__ == "__main__":
    main()

Submission status: Accepted

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

res = "No"

#check line
if not(any([A[0], A[1], A[2]])) or not(any([A[3], A[4], A[5]])) or not(any([A[6], A[7], A[8]])):
  res = "Yes"

#check colmun
if not(any([A[0], A[3], A[6]])) or not(any([A[1], A[4], A[7]])) or not(any([A[2], A[5], A[8]])):
  res = "Yes"

#check diag
if not(any([A[0], A[4], A[8]])) or not(any([A[2], A[4], A[6]])):
  res = "Yes"
print(res)

Submission status: Accepted

Solution code:
import numpy as np
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = []
for j in range(N):
    b = int(input())
    B.append(b)
A = np.array(A)
B = np.array(B)
boolean_matrix = np.isin(A, B)
if boolean_matrix.sum(axis=1).max() >= 3 or \
   boolean_matrix.sum(axis=0).max() >= 3 or \
   np.diag(boolean_matrix).sum() >= 3 or \
   np.diag(np.fliplr(boolean_matrix)).sum() >= 3:
    print('Yes')
else:
    print('No')