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:
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
list=[int(input()) for _ in range(n)]
for i in range(n):
    for j in range(3):
        if list[i]==a1[j]:
            a1[j]=101
        elif list[i]==a2[j]:
            a2[j]=101
        elif list[i]==a3[j] :
            a3[j]=101

if a1[0]==a2[0]==a3[0]==101:
    print("Yes")
elif a1[1]==a2[1]==a3[1]==101:
    print("Yes")
elif a1[2]==a2[2]==a3[2]==101:
    print("Yes")
elif a1[0]==a1[1]==a1[2]==101:
    print("Yes")
elif a2[0]==a2[1]==a2[2]==101:
    print("Yes")
elif a3[0]==a3[1]==a3[2]==101:
    print("Yes")
elif a1[0]==a2[1]==a3[2]==101:
    print("Yes")
elif a1[2]==a2[1]==a3[0]==101:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import numpy as np

# input = sys.stdin.readline

bingo = [list(map(int, input().split())) for ii in range(3)]

n = int(input())

num = []
for ii in range(n):
    num.append(int(input()))

bi = np.full(9, False)

bingo_np = np.array(bingo).reshape(-1)

for number in num:
    for i in range(9):
        if bingo_np[i] == number:
            bi[i] = True
if (np.all(bi[:3])):
    print("Yes")
elif (np.all(bi[3:6])):
    print("Yes")
elif (np.all(bi[6:9])):
    print("Yes")
elif (np.all([bi[0], bi[3], bi[6]])):
    print("Yes")
elif (np.all([bi[1], bi[4], bi[7]])):
    print("Yes")
elif (np.all([bi[2], bi[5], bi[8]])):
    print("Yes")
elif (np.all([bi[0], bi[4], bi[8]])):
    print("Yes")
elif (np.all([bi[2], bi[4], bi[6]])):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
bingo=[]
for i in range(3):
  num=list(map(int,input().split()))
  bingo.append(num)
N=int(input())
atari=[0,0,0,0,0,0,0,0,0]
for i in range(N):
  num=int(input())
  for j in range(9):
    if bingo[j//3][j%3]==num:
      atari[j]=1

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

Submission status: Accepted

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

ac = [[0] * 3 for i in range(3)]


for i in range(3):
  for k in range(3):
    for f in range(len(b)):
        if b[f] == a[i][k]:
            ac[i][k]= 1
 
bingo =0

if ac[0][0]+ac[0][1]+ac[0][2] ==3:
  bingo +=1
if ac[1][0]+ac[1][1]+ac[1][2] ==3:
  bingo +=1
if ac[2][0]+ac[2][1]+ac[2][2] ==3:
  bingo +=1

if ac[0][0]+ac[1][0]+ac[2][0] ==3:
  bingo +=1
if ac[0][1]+ac[1][1]+ac[1][1] ==3:
  bingo +=1
if ac[0][2]+ac[1][2]+ac[2][2] ==3:
  bingo +=1
  
if ac[0][0]+ac[1][1]+ac[2][2] ==3:
  bingo +=1
if ac[2][0]+ac[1][1]+ac[0][2] ==3:
  bingo +=1
  
if bingo >0: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
N = int(input())
ans =[[0,0,0],
      [0,0,0],
      [0,0,0]]
# print(ans)

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

for i in d:
  for j in range(len(a)):
    if a[j] == i:
      ans[0][j] = 1
  for j in range(len(b)):
    if b[j] == i:
      ans[1][j] = 1
  for j in range(len(c)):
    if c[j] == i:
      ans[2][j] = 1
# print(ans)
answer = "No"
# 横
if ans[0][0] == 1 and ans[0][1] == 1 and ans[0][2] == 1:
  answer = "Yes"
if ans[1][0] == 1 and ans[1][1] == 1 and ans[1][2] == 1:
  answer = "Yes"
if ans[2][0] == 1 and ans[2][1] == 1 and ans[2][2] == 1:
  answer = "Yes"
if ans[0][1] == 1 and ans[1][1] == 1 and ans[2][2] == 1:
  answer = "Yes"

# 縦
if ans[0][0] == 1 and ans[1][0] == 1 and ans[2][0] == 1:
  answer = "Yes"
if ans[0][1] == 1 and ans[1][1] == 1 and ans[2][1] == 1:
  answer = "Yes"
if ans[0][2] == 1 and ans[1][2] == 1 and ans[2][2] == 1:
  answer = "Yes"

# 斜め
if ans[0][2] == 1 and ans[1][1] == 1 and ans[2][0] == 1:
  answer = "Yes"
if ans[0][0] == 1 and ans[1][1] == 1 and ans[2][2] == 1:
  answer = "Yes"

print(answer)

Submission status: Accepted

Solution code:
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = [int(input()) for _ in range(n)]
for i in range(len(a)):
    for o in range(len(a[1])):
        if a[i][o] in b:
            a[i][o] = 0
for i in a:
    if i == [0,0,0]:
        print("Yes")
        quit()
for i in range(3):
    if a[0][i] == 0 and a[1][i] ==0 and a[2][i] ==0:
        print("Yes")
        quit()
if a[0][0] == 0 and a[2][2] ==0 and a[1][1] == 0:
    print("Yes")
    quit()
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] ==0:
    print("Yes")
    quit()
print("No")

Submission status: Accepted

Solution code:
def checkbingo(bingo,bs):
  for b in bingo:
    cnt = 0
    for n in bs:
      if n in b:
        cnt +=1
    if cnt == len(b):
      return True
  return False

list1 = input('').split(' ')
list2 = input('').split(' ')
list3 = input('').split(' ')
bingo = [list1,list2,list3]
bingo.append([list1[0],list2[0],list3[0]])
bingo.append([list1[1],list2[1],list3[1]])
bingo.append([list1[2],list2[2],list3[2]])
bingo.append([list1[0],list2[1],list3[2]])
bingo.append([list1[2],list2[1],list3[0]])
max_n = int(input(''))
bs = []
result = False
for n in range(0,max_n):
  bs.append(input(''))

if checkbingo(bingo,bs):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
mat = [list(map(int,input().split())) for i in range(3)]
mat = mat[0]+mat[1]+mat[2]

n = int(input())
for _ in range(n):
  m = int(input())
  for i in range(9):
    if mat[i] == m:
      mat[i] = 1000

if sum(mat[:3])>=3000:
  print("Yes")
elif sum(mat[3:6])>=3000:
  print("Yes")
elif sum(mat[6:])>=3000:
  print("Yes")
elif sum(mat[::3])>=3000:
  print("Yes")
elif sum(mat[1::3])>=3000:
  print("Yes")
elif sum(mat[2::3])>=3000:
  print("Yes")
elif sum(mat[::4])>=3000:
  print("Yes")
elif sum(mat[2:7:2])>=3000:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys
a1 = list(map(lambda x: int(x),input().split()))
a2 = list(map(lambda x: int(x),input().split()))
a3 = list(map(lambda x: int(x),input().split()))

ans = []
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1 :
        a1[a1.index(b)] = 101
    if b in a2 :
        a2[a2.index(b)] = 101
    if b in a3 :
        a3[a3.index(b)] = 101

for i in range(3) :
    if a1[i] == 101 and a2[i] == 101 and a3[i] == 101 :
        print('Yes')
        sys.exit()

if a1.count(101) == 3 or a2.count(101) == 3 or a3.count(101) == 3 :
    print('Yes')
    sys.exit()

if a1[0] == 101 and a2[1] == 101 and a3[2] == 101 :
    print('Yes')
    sys.exit()

if a1[2] == 101 and a2[1] == 101 and a3[0] == 101 :
    print('Yes')
    sys.exit()
print('No')

Submission status: Accepted

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

i=0
A = []
while i < 3: 
    m = map(int, input().split())
    A.append(list(m))
    i+=1
#print(A)
n=int(input())

i=0
lst = []
while i < n: 
    b = int(input())
    lst.append(b)
    i+=1
#print(lst)
a= {}
for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in lst:
            a[str(i)+str(j)] = 1
        else:
            a[str(i)+str(j)] = 0


if a["00"] + a["01"]+ a["02"] == 3 \
    or a["10"] + a["11"] + a["12"] == 3 \
    or a["20"] + a["21"] + a["22"] == 3 \
    or a["00"] + a["10"] + a["20"] == 3 \
    or a["01"] + a["11"] + a["21"] == 3 \
    or a["02"] + a["12"] + a["22"] == 3 \
    or a["00"] + a["11"] + a["22"] == 3  \
    or a["02"] + a["11"] + a["20"] == 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = []
bingo = []
for i in range(3):
    A.append(list(map(int, input().split())))
    bingo.append([False] * 3)

N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            idx = A[j].index(b)
            bingo[j][idx] = True

# check
migiue = True
migisita = True
okFlg = False
for i in range(3):
    tate = True
    yoko = True
    for j in range(3):
        if bingo[i][j] == False:
            yoko = False
        if bingo[j][i] == False:
            tate = False
    if tate or yoko:
        okFlg = True
        break
    if bingo[i][i] == False:
        migisita = False
    if bingo[i][-i - 1] == False:
        migiue = False

if migiue or migisita:
    if okFlg == False:
        okFlg = True
print('YNeos'[not okFlg::2])

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())
b_lst = [int(input()) for _ in range(n)]
a_lst = a1 + a2 + a3

for i in range(len(b_lst)):
    if b_lst[i] in a_lst:
        a_lst[a_lst.index(b_lst[i])] = 0

ans = 0

for i in range(3):
    if a_lst[i] == a_lst[i+3] == a_lst[i+6] == 0:
        print("Yes")
        ans = 1
        break
    elif a_lst[3*i] == a_lst[3*i+1] == a_lst[3*i+2] == 0:
        print("Yes")
        ans = 1
        break
    elif a_lst[2] == a_lst[4] == a_lst[6] == 0 or a_lst[0] == a_lst[4] == a_lst[8] == 0:
        print("Yes")
        ans = 1
        break

if ans == 0:
    print("No")

Submission status: Accepted

Solution code:
a = []
for i in range(3):
    a.append(list(map(int,input().split())))
N=int(input())
b = [int(input()) for i in range(N)]
c=[[0,0,0],[0,0,0],[0,0,0]]
if a[0][0] in b:
    c[0][0]=1
if a[0][1] in b:
    c[0][1]=1
if a[0][2] in b:
    c[0][2]=1
if a[1][0] in b:
    c[1][0]=1
if a[1][1] in b:
    c[1][1]=1
if a[1][2] in b:
    c[1][2]=1
if a[2][0] in b:
    c[2][0]=1
if a[2][1] in b:
    c[2][1]=1
if a[2][2] in b:
    c[2][2]=1

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

Submission status: Accepted

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

ans = [["_" for _ in range(3)] for _ in range(3)]
bingo = False

for i in b:
  for j in range(3):
    for k in range(3):
      if i == A[j][k]:
        ans[j][k] = "〇"
        
for i in range(3):        
  if ans[i][0] == ans[i][1] == ans[i][2] == "〇":
    bingo = True
  if ans[0][i] == ans[1][i] == ans[2][i] == "〇":
    bingo = True

if ans[0][0] == ans[1][1] == ans[2][2] == "〇":
  bingo = True
if ans[0][2] == ans[1][1] == ans[2][0] == "〇":
  bingo = True
  
if bingo:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys

A = list(map(int, input().split()))
A1 =  list(map(int, input().split()))
A2 =  list(map(int, input().split()))

bingo_lis = A + A1 + A2




N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))  # S += [input()] とも書ける


lis=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[2,4,6],[0,4,8]]


for i in range(len(lis)):
    tmp_lis = lis[i]
    ans = 0
    for j in tmp_lis:
        if bingo_lis[j] in b:
            ans = ans + 1
    if ans == 3:
        print("Yes")
        sys.exit()
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())
b = [int(input()) for i in range(n)]

for i in b:
    for j in range(3):
        if i == a1[j]:
            a1[j] = "x"
        if i == a2[j]:
            a2[j] = "x"
        if i == a3[j]:
            a3[j] = "x"
            
if a1.count("x") == 3 or a2.count("x") == 3 or a3.count("x") == 3:
    print("Yes")
elif a1[0] == "x" and a2[0] == "x" and a3[0] == "x":
    print("Yes")
elif a1[1] == "x" and a2[1] == "x" and a3[1] == "x":
    print("Yes")
elif a1[2] == "x" and a2[2] == "x" and a3[2] == "x":
    print("Yes")
elif a1[0] == "x" and a2[1] == "x" and a3[2] == "x":
    print("Yes")
elif a1[2] == "x" and a2[1] == "x" and a3[0] == "x":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = []
for _ in range(3):
  A += list(map(int,input().split()))
n = int(input())
ans = [0]*9
for _ in range(n):
  b = int(input())
  if b in A:
    i = A.index(b)
    if i != -1:
      ans[i] = 1
bingo = [0b111000000,0b000111000,0b000000111,0b100100100,0b010010010,0b001001001,0b100010001,0b001010100]
f = 0
sheet = 0
for i in range(9):
  sheet += ans[i] * 2 ** (8 - i)
for i in range(8):
  ansb = sheet & bingo[i]
  if (ansb & bingo[i]) in bingo:
    f = 1
    break
if f == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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


if a[0][0] in b and a[0][1] in b and a[0][2] in b:
    print("Yes")
    exit()
elif a[1][0] in b and a[1][1] in b and a[1][2] in b:
    print("Yes")
    exit()
elif a[2][0] in b and a[2][1] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[0][0] in b and a[1][0] in b and a[2][0] in b:
    print("Yes")
    exit()
elif a[0][1] in b and a[1][1] in b and a[2][1] in b:
    print("Yes")
    exit()
elif a[0][2] in b and a[1][2] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[2][0] in b and a[1][1] in b and a[0][2] in b:
    print("Yes")
    exit()
else:
    print("No")

Submission status: Accepted

Solution code:

def read_input():
    cards = []
    for i in range(3):
        r = list(map(int, input().split()))
        cards.append(r)

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

    return cards, blist


def get_row(cards, i):
    return cards[i]


def get_col(cards, i):
    col = [cards[j][i] for j in range(3)]
    return col


def get_diag(cards):
    diag = [cards[i][i] for i in range(3)]
    return diag


def get_re_diag(cards):
    diag = [cards[i][2 - i] for i in range(3)]
    return diag


def submit():
    cards, blist = read_input()

    numbers = set(blist)
    bingo = False
    for i in range(3):
        r = get_row(cards, i)
        if set(r) <= numbers:
            print("Yes")
            return

        c = get_col(cards, i)
        if set(c) <= numbers:
            print("Yes")
            return

    if set(get_diag(cards)) <= numbers:
        print("Yes")
        return

    if set(get_re_diag(cards)) <= numbers:
        print("Yes")
        return

    print("No")


if __name__ == "__main__":
    submit()

Submission status: Accepted

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

n = int(input())

ans = []
for _ in range(3):
  ans += [0]*3
  
for _ in range(n):
  b = int(input())
  if b in a:
    ans[a.index(b)] = 1
    
f = False
for i in range(3):
  if sum(ans[3*i:3*i+3]) == 3:
    f = True

for i in range(3):
  if sum(ans[i::3]) == 3:
    f = True
    
if (ans[0] + ans[4] + ans[8]) == 3:
  f = True
if (ans[2] + ans[4] + ans[6]) == 3:
  f = True
  
if f:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

N = int(input())

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

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

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

Submission status: Accepted

Solution code:
A = [0]*3
for i in range(0,3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
 
count = 0
while count < N:
    for i in range(0,3):
      for j in range(0,3):
        if b[count] == A[i][j]:
          A[i][j] = 0
    count += 1
            

sum_y = [0]*3                
for i in range(0,3):
  for j in range(0,3):
    sum_y[i] += A[i][j]#横
 
sum_t = [0]*3
for i in range(0,3):
  for j in range(0,3):
    sum_t[i] += A[j][i]
    
 
sum1 = A[0][0] + A[1][1] + A[2][2]
sum2 = A[0][2] + A[1][1] + A[0][2]
 
if sum_y[0] == 0:
    print("Yes")
elif sum_y[1] == 0:
    print("Yes")
elif sum_y[2] == 0:
    print("Yes")
elif sum_t[0] == 0:
    print("Yes") 
elif sum_t[1] == 0:
    print("Yes") 
elif sum_t[2] == 0:
    print("Yes") 
elif sum1 == 0:
  print("Yes")
elif sum2 == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    A_1 = list(map(int,input().split()))
    A_2 = list(map(int,input().split()))
    A_3 = list(map(int,input().split()))

    A = [A_1,A_2,A_3]
    N = int(input())
    bingo = [[0] * 4 for _ in range(4)]
    for _ in range(N):
        b = int(input())

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


    for i in range(4):
        if bingo[i][0] == bingo[i][1] == bingo[i][2] == 1:
            print("Yes")
            exit()
        elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 1:
            print("Yes")
            exit()


    if bingo[0][2] == bingo[1][1] == bingo[2][0] == 1:
        print("Yes")
        exit()
    elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 1:
        print("Yes")
        exit()

    print("No")



if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
list_row1= list(map(int, input().split()))
list_row2= list(map(int, input().split()))
list_row3= list(map(int, input().split()))
N = int(input())
list_b = []
for i in range(N):
    list_b.append(int(input()))
list_col1 = [list_row1[0], list_row2[0], list_row3[0]]
list_col2 = [list_row1[1], list_row2[1], list_row3[1]]
list_col3 = [list_row1[2], list_row2[2], list_row3[2]]
list_sla1 = [list_row1[0], list_row2[1], list_row3[2]]
list_sla2 = [list_row1[2], list_row2[1], list_row3[0]]
bingo_list = [list_row1, list_row2, list_row3, list_col1, list_col2, list_col3, list_sla1, list_sla2]
for lists in bingo_list:
    cnt = 0
    for i in range(3):
        if lists[i] in list_b:
            cnt += 1
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
A=[]
m=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
def add(n):
    for i in range(3):
        if n in A[i]:
            m[i][A[i].index(n)]=1

def check():
    for i in m:
        if i == [1,1,1]:
            return True
    for i in range(3):
        if m[0][i]+m[1][i]+m[2][i]==3:
            return True
    if m[0][0]+m[1][1]+m[2][2]==3:
        return True
    if m[2][0]+m[1][1]+m[0][2]==3:
        return True
    return False

for i in range(N):
    inp=int(input())
    add(inp)
    if check():
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
import numpy as np

a = [input().split() for l in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
bingo = 0
wa = 0

a = np.array(a)

i = 0
while i < N:
    for j in range(3):
        for h in range(3):
            if int(a[j,h]) == int(b[i]):
                a[j,h] = 0
    i = i + 1

for j in range(3):
    wa = a[j,0] + a[j,1] + a[j,2]
    if int(wa) == 0:
        bingo = 1

for h in range(3):
    wa = a[0,h] + a[1,h] + a[2,h]
    if int(wa) == 0:
        bingo = 1

if int(a[0,0]+a[1,1]+a[2,2]) == 0:
    bingo = 1

if int(a[0,2]+a[1,1]+a[2,0]) == 0:
    bingo = 1
    
if bingo == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
bingo = np.zeros([3, 3])

n = int(input())
for _ in range(n):
    b = int(input())
    bingo[card == b] = 1

if np.any(np.all(bingo == 1, axis=1)):
    print('Yes')
elif np.any(np.all(bingo == 1, axis=0)):
    print('Yes')
elif (bingo[0, 0] == 1 and bingo[1, 1] == 1 and bingo[2, 2] == 1) or \
      (bingo[0, 2] == 1 and bingo[1, 1] == 1 and bingo[2, 0] == 1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
g,h,i = map(int, input().split())
bingo = [a,b,c,d,e,f,g,h,i]

n = int(input())

for i in range(n):
  num = int(input())
  if num in bingo:
    bingo = [str(bingo[i]) for i in range(len(bingo))]
    bingo[bingo.index(str(num))] = 0
    bingo = [int(bingo[i]) for i in range(len(bingo))]

ans1 = bingo[0]+bingo[1]+bingo[2] 
ans2 = bingo[3]+bingo[4]+bingo[5]
ans3 = bingo[6]+bingo[7]+bingo[8]
ans4 = bingo[0]+bingo[3]+bingo[6]
ans5 = bingo[1]+bingo[4]+bingo[7]
ans6 = bingo[2]+bingo[5]+bingo[8]
ans7 = bingo[0]+bingo[4]+bingo[8]
ans8 = bingo[2]+bingo[4]+bingo[6]

if ans1==0 or ans2==0 or ans3==0 or ans4==0 or ans5==0 or ans6==0 or ans7==0 or ans8==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 24 14:37:00 2020

@author: matsui
"""
import numpy as np
bingo=np.zeros([3,3])
result=np.zeros([3,3])
A=input().split()
bingo[0,0]=int(A[0])
bingo[0,1]=int(A[1])
bingo[0,2]=int(A[2])
A=input().split()
bingo[1,0]=int(A[0])
bingo[1,1]=int(A[1])
bingo[1,2]=int(A[2])
A=input().split()
bingo[2,0]=int(A[0])
bingo[2,1]=int(A[1])
bingo[2,2]=int(A[2])

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: result[j,k]=1

ans='No'
if result[0,0]==1 and result[0,1]==1 and result[0,2]==1: ans='Yes'
if result[1,0]==1 and result[1,1]==1 and result[1,2]==1: ans='Yes'
if result[2,0]==1 and result[2,1]==1 and result[2,2]==1: ans='Yes'

if result[0,0]==1 and result[1,0]==1 and result[2,0]==1: ans='Yes'
if result[0,1]==1 and result[1,1]==1 and result[2,1]==1: ans='Yes'
if result[0,2]==1 and result[1,2]==1 and result[2,2]==1: ans='Yes'

if result[0,0]==1 and result[1,1]==1 and result[2,2]==1: ans='Yes'
if result[0,2]==1 and result[1,1]==1 and result[2,0]==1: ans='Yes'

print(ans)
#print(bingo)
#print(result)

Submission status: Accepted

Solution code:
import numpy as np

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

n = int(input())

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

ans = np.zeros((3,3))

for i in range(n):
    ans += np.where(l == li[i], 1, 0)

count = 0
c = 1
for i in range(3):
    c *= ans[i,0]
count += c
c = 1

for i in range(3):
    c *= ans[i,1]
count += c
c = 1

for i in range(3):
    c *= ans[i,2]
count += c
c = 1

for i in range(3):
    c *= ans[0,i]
count += c
c = 1

for i in range(3):
    c *= ans[1,i]
count += c
c = 1

for i in range(3):
    c *= ans[2,i]
count += c
c = 1

for i in range(3):
    c *= ans[i,0]
count += c
c = 1

for i in range(3):
    c *= ans[i,i]
count += c
c = 1

for i in range(3):
    c *= ans[i,2-i]
count += c

if count != 0:
    print("Yes")
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
from sys import stdin


def get_result(data):
    A = np.array([data[0], data[1], data[2]])
    N = data[3][0]
    B = [data[i+4][0] for i in range(N)]
    for i in range(3):
        for j in range(3):
            if A[i, j] in B:
                A[i, j] = 1
            else:
                A[i, j] = 0
    # judge bingo
    tmp = []
    for i in range(3):
        tmp.append(sum(A[:, i]))
        tmp.append(sum(A[i, :]))
    tmp.append(A[0,0]+ A[1,1]+A[2,2])
    tmp.append(A[0,2]+ A[1,1]+A[2,0])
    return 'Yes' if 3.0 in tmp else 'No'

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

bing = [list(map(int, input().split())) for i in range(3)]
n = int(input())
line = [int(input()) for i in range(n)]

ans = [[0,0,0], [0,0,0], [0,0,0]]
for l in line:
    for i in range(3):
        for j in range(3):
            if l == bing[i][j]:
                ans[i][j] = bing[i][j]

# 横比較
for l in ans:
    if 0 not in l:
        print("Yes")
        sys.exit()

# 縦比較
for i in range(3):
    if ans[0][i] != 0 and ans[1][i] != 0 and ans[2][i] != 0:
        print("Yes")
        sys.exit()

# 斜め比較
if ans[0][0] != 0 and ans[1][1] != 0 and ans[2][2] != 0:
    print("Yes")
elif ans[0][2] != 0 and ans[1][1] != 0 and ans[2][0] != 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = []
a.append(list(input().split()))
a.append(list(input().split()))
a.append(list(input().split()))
flag = [[False]*3]*3

n = int(input())

for i in range(n):
  b = input()
  for j in range(3):
    for k in range(3):
      if (a[j][k] == b):
        a[j][k] = 0
        
# ビンゴのチェック
ans = 'No'
# 横
for i in range(3):
  if (a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
    ans = 'Yes'
# 縦
for i in range(3):
  if (a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0):
    ans = 'Yes'
# 斜め
if (a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
  ans = 'Yes'
elif (a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
  ans = 'Yes'

print(ans)

Submission status: Accepted

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

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

# print(a)
# print(b)

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

tmp = 0
if a[0][0] + a[1][1] + a[2][2] == 0:
    tmp = 1
if a[0][2] + a[1][1] + a[2][0] == 0:
    tmp = 1
if a[0][0] + a[0][1] + a[0][2] == 0:
    tmp = 1
if a[1][0] + a[1][1] + a[1][2] == 0:
    tmp = 1
if a[2][0] + a[2][1] + a[2][2] == 0:
    tmp = 1
if a[0][0] + a[1][0] + a[2][0] == 0:
    tmp = 1
if a[0][1] + a[1][1] + a[2][1] == 0:
    tmp = 1
if a[0][2] + a[1][2] + a[2][2] == 0:
    tmp = 1

if tmp == 1:
    print("Yes")
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())
B = [int(input()) for _ in range(N)]

for b in B:
    for i in range(3):
        if b == A1[i]:
            A1[i] = 0
        if b == A2[i]:
            A2[i] = 0
        if b == A3[i]:
            A3[i] = 0


if ((A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or
    (A1[1] == 0 and A2[1] == 0  and A3[1] == 0) or
    (A1[2] == 0 and A2[2] == 0  and A3[2] == 0) or
    (A1[0] == 0 and A1[1] == 0  and A1[2] == 0) or
    (A2[0] == 0 and A2[1] == 0  and A2[2] == 0) or
    (A3[0] == 0 and A3[1] == 0  and A3[2] == 0) or
    (A1[0] == 0 and A2[1] == 0  and A3[2] == 0) or
    (A1[2] == 0 and A2[1] == 0  and A3[0] == 0)):
    print('Yes')
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())
s = [int(input()) for i in range(N)]

Alist = A1+A2+A3
A = [0]*len(Alist)

for i in range(len(Alist)):
    if s.count(Alist[i])>0:
        A[i]=1

if A[0]+A[1]+A[2]>2 or A[3]+A[4]+A[5]>2 or A[6]+A[7]+A[8]>2 or A[0]+A[3]+A[6]>2 or A[1]+A[4]+A[7]>2 or A[2]+A[5]+A[8]>2 or A[0]+A[4]+A[8]>2 or A[2]+A[4]+A[6]>2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

a2 = []#たて
a3 = []#ななめ

for i in range(3):
    a2.append([a[0][i], a[1][i], a[2][i]])

a3.append([a[0][0], a[1][1], a[2][2]])
a3.append([a[0][2], a[1][1], a[2][0]])

for i in range(3):
    for _b in b:
        if _b in a[i]:
            a[i].remove(_b)

for i in range(3):
    if len(a[i]) == 0:
        print("Yes")
        exit()

for i in range(3):
    for _b in b:
        if _b in a2[i]:
            a2[i].remove(_b)

for i in range(3):
    if len(a2[i]) == 0:
        print("Yes")
        exit()

for i in range(2):
    for _b in b:
        if _b in a3[i]:
            a3[i].remove(_b)

for i in range(2):
    if len(a3[i]) == 0:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
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):
  b = int(input())
  for k in range(3):
    if A[k]==b:
      A[k]=0
    if B[k]==b:
      B[k]=0
    if C[k]==b:
      C[k]=0 
if (A[0]==A[1]==A[2]) or (B[0]==B[1]==B[2]) or (C[0]==C[1]==C[2]) or (A[0]==B[0]==C[0]) or (A[1]==B[1]==C[1]) or (A[2]==B[2]==C[2]) or(A[0]==B[1]==C[2]) or (A[2]==B[1]==C[0]):
  print('Yes')
else:
  print('No')