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:

A = []
for _ in range(3):
    temp = [int(s) for s in input().split()]
    A += temp
# print(A)

N = int(input())
# print(N)

b_list = [int(input()) for _ in range(N)]
# print(b_list)

R = [False] * 9
for i, n in enumerate(A):
    R[i] = n in b_list


def check_bingo(table, check_index):
    for i in check_index:
        if not table[i]:
            return False
    return True

def check_table(table):
    check_list = [
        [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 check_index in check_list:
        if check_bingo(table, check_index):
            return True
    return False


result = "Yes" if check_table(R) else "No"
print(result)

Submission status: Accepted

Solution code:
a0, a1, a2 = map(int, input().split())
b0, b1, b2 = map(int, input().split())
c0, c1, c2 = map(int, input().split())
yoko0 = [a0, a1, a2]
yoko1 = [b0, b1, b2]
yoko2 = [c0, c1, c2]
tate0 = [a0, b0, c0]
tate1 = [a1, b1, c1]
tate2 = [a2, b2, c2]
naname0 = [a0, b1, c2]
naname1 = [a2, b1, c0]
n = int(input())
for i in range(n):
    m = int(input())
    if m in yoko0:
        yoko0.remove(m)
    if m in yoko1:
        yoko1.remove(m)
    if m in yoko2:
        yoko2.remove(m)
    if m in tate0:
        tate0.remove(m)
    if m in tate1:
        tate1.remove(m)
    if m in tate2:
        tate2.remove(m)
    if m in naname0:
        naname0.remove(m)
    if m in naname1:
        naname1.remove(m)
if yoko0 == [] or yoko1 == [] or yoko2 == [] or tate0 == [] or tate1 == [] or tate2 == [] or naname0 == [] or naname1 == []:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A_1=list(map(int,input().split()))
A_2=list(map(int,input().split()))
A_3=list(map(int,input().split()))
N=int(input())
b=list(int(input()) for i in range(N))

for i in range(N):
    for j in range(3):
        if b[i] == A_1[j]:
            A_1[j]=0
        elif b[i] == A_2[j]:
            A_2[j]=0
        elif b[i] == A_3[j]:
            A_3[j]=0

A=A_1+A_2+A_3
if A[0]==A[1] and A[0]==A[2]:
    print('Yes')
elif A[3]==A[4] and A[3]==A[5]:
    print('Yes')
elif A[6]==A[7] and A[6]==A[8]:
    print('Yes')
elif A[0]==A[4] and A[0]==A[8]:
    print('Yes')
elif A[2]==A[4] and A[2]==A[6]:
    print('Yes')
elif A[0]==A[3] and A[0]==A[6]:
    print('Yes')
elif A[1]==A[4] and A[1]==A[7]:
    print('Yes')
elif A[2]==A[5] and A[2]==A[8]:
    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)]

card = [[0, 0, 0],
              [0, 0, 0],
              [0, 0, 0]]
bingo  = False

# 穴あけ
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            card[i][j] = 1

# ビンゴ！？
# 縦横１列
for i in range(3):
    if sum(card[i])==3:
        bingo = True
        break
    if (card[0][i]+card[1][i]+card[2][i])==3:
        bingo = True
        break

# 斜め
if ~bingo and card[1][1]==1:
    if card[0][0] == 1 and card[2][2]==1:
        bingo = True
    if card[0][2] == 1 and card[2][0]==1:
        bingo = True
if bingo:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from itertools import combinations as comb

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)]

bingo = [[8, 1, 6], [3, 5, 7], [4, 9, 2]]
check = []

for i in range(N):
    for j in range(3):
        if b[i] == A1[j]:
            check.append(bingo[0][j])
            break
        elif b[i] == A2[j]:
            check.append(bingo[1][j])
            break
        elif b[i] == A3[j]:
            check.append(bingo[2][j])
            break

flag = False
for i in list(comb(check, 3)):
    if sum(i) == 15:
        flag = True
        break

print("Yes" if flag else "No")

Submission status: Accepted

Solution code:
a1,a2,a3 = map(int, input().split())
a4,a5,a6 = map(int, input().split())
a7,a8,a9 = map(int, input().split())
n = int(input())
b = [int(input()) for i in range(n)]
a = [a1,a2,a3,a4,a5,a6,a7,a8,a9]
for i in range(9):
    if a[i] in b:
        a[i] = 0
if a[0:3] ==[0,0,0] or a[3:6] ==[0,0,0] or a[6:9] ==[0,0,0] or [a[0],a[3],a[6]] ==[0,0,0] or [a[1],a[4],a[7]]==[0,0,0] or [a[2],a[5],a[8]]==[0,0,0] or [a[0],a[4],a[8]]==[0,0,0] or [a[2],a[4],a[6]]==[0,0,0]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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


def main():
    bingo_card_number = [list(map(int, input().split())) for i in range(3)]
    n = int(input())
    number_called = [int(input()) for i in range(n)]

    bingo_card = [[0] * 3 for _ in range(3)]

    for i, row in enumerate(bingo_card_number):
        for j, cell in enumerate(row):
            if cell in number_called:
                bingo_card[i][j] = 1

    result = "No"
    for i in range(3):

        if sum(bingo_card[i]) == 3:
            result = "Yes"

        if bingo_card[0][i] + bingo_card[1][i] + bingo_card[2][i] == 3:
            result = "Yes"

    if bingo_card[0][0] + bingo_card[1][1] + bingo_card[2][2] == 3\
        or bingo_card[2][0] + bingo_card[1][1] + bingo_card[0][2] == 3:
        result = "Yes"


    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np


def main():
    bingo_card = np.array([list(map(int, input().split())) for _ in range(3)])
    counter = int(input())

    for _ in range(counter):
        bingo_card = np.where(bingo_card == int(input()), 0, bingo_card)

    vertical_bingo = min(np.sum(bingo_card, axis=0)) == 0
    horizontal_bingo = min(np.sum(bingo_card, axis=1)) == 0

    diag_normal_bingo = bingo_card[0][0] == 0 and bingo_card[1][1] == 0 and bingo_card[2][2] == 0
    diag_reverse_bingo = bingo_card[0][2] == 0 and bingo_card[1][1] == 0 and bingo_card[2][0] == 0

    if vertical_bingo or horizontal_bingo or diag_normal_bingo or diag_reverse_bingo:
        print('Yes')
        exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# ２次元配列を１次元配列にする方法
a = sum([input().split() for i in range(3)], [])
# list文字列リストを数値リストに変換
a = [int(i) for i in a]
count = int(input())
if count < 3:
    print("No")
else:
    num = int(input())
    a = [-1 if int(i) == num else i for i in a]
    num = int(input())
    a = [-1 if int(i) == num else i for i in a]
    counter = 3
    d = False
    while (counter <= count):
        counter += 1
        num = int(input())
        a = [-1 if int(i) == num else i for i in a]
        point = sum(i == -1 for i in a)
        if point >= 3 and (sum(a[0:3]) == -3 or sum(a[3:6]) == -3 or sum(a[6:9]) == -3 or sum(a[0::3]) == -3 or sum(
                a[1::3]) == -3 or sum(a[2::3]) == -3 or sum(a[0::4]) == -3 or sum(a[2:7:2]) == -3):
            print("Yes")
            d = True
            break
    if not d:
        print("No")

Submission status: Accepted

Solution code:
Size = 3

A = [list(input().split()) for _ in range(Size)]
n = int(input())
b = [input() for _ in range(n)]

bingo = False
for row in A:
    if all(item in b for item in row):
        bingo = True
for col in zip(*A):
    if all(item in b for item in col):
        bingo = True
if all(A[i][i] in b for i in range(Size)):
    bingo = True
if all(A[i][Size - 1 - i] in b for i in range(Size)):
    bingo = True

print("Yes" if bingo else "No")

Submission status: Accepted

Solution code:
Size = 3

A = [list(map(int, input().split())) for _ in range(Size)]
n = int(input())

for _ in range(n):
    b = int(input())
    for i in range(Size):
        for j in range(Size):
            if A[i][j] == b:
                A[i][j] = 0

bingo = False
for row in A:
    if sum(row) == 0:
        bingo = True
for col in zip(*A):
    if sum(col) == 0:
        bingo = True
if sum(A[i][i] for i in range(Size)) == 0:
    bingo = True
if sum(A[i][Size - 1 - i] for i in range(Size)) == 0:
    bingo = True

print("Yes" if bingo else "No")

Submission status: Accepted

Solution code:
import sys
A1=map(int, sys.stdin.readline().split())
A2=map(int, sys.stdin.readline().split())
A3=map(int, sys.stdin.readline().split())
A=A1+A2+A3
N=input()

def isbingo():
    if A[0]==A[1]==A[2]==0: return True
    elif A[3]==A[4]==A[5]==0: return True
    elif A[6]==A[7]==A[8]==0: return True
    elif A[0]==A[3]==A[6]==0: return True
    elif A[1]==A[4]==A[7]==0: return True
    elif A[2]==A[5]==A[8]==0: return True
    elif A[0]==A[4]==A[8]==0: return True
    elif A[2]==A[4]==A[6]==0: return True
    else: return False

for _ in range(N):
    b=int(sys.stdin.readline().strip())
    for i,a in enumerate(A):
        if b==a:
            A[i]=0

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

Submission status: Accepted

Solution code:
a1 = list(input().split())
a2 = list(input().split())
a3 = list(input().split())

n = int(input())

for _ in range(n):
    b = input()
    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 a1[1]==0 and a1[2]==0:
    print('Yes')
elif a2[0]==0 and a2[1]==0 and a2[2]==0:
    print('Yes')
elif a3[0]==0 and a3[1]==0 and a3[2]==0:
    print('Yes')
elif a1[0]==0 and a2[0]==0 and a3[0]==0:
    print('Yes')
elif a1[1]==0 and a2[1]==0 and a3[1]==0:
    print('Yes')
elif a1[2]==0 and a2[2]==0 and a3[2]==0:
    print('Yes')
elif a1[0]==0 and a2[1]==0 and a3[2]==0:
    print('Yes')
elif a1[2]==0 and a2[1]==0 and a3[0]==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = []
A_1 = list(map(int,input().split()))
A_2 = list(map(int,input().split()))
A_3 = list(map(int,input().split()))
A.append(A_1)
A.append(A_2)
A.append(A_3)
B = []
check=0
BingocountR=0
BingocountG=0
N = int(input())
ArrayBingo =[[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
    B.append(int(input()))
for j in range (3):
    for k in range (3):
        for l in range (N):
            if A[j][k]==B[l]:
                ArrayBingo[j][k]=1
for i in range(3):
    for j in range(3):
        if ArrayBingo[j][i]==1:
            BingocountR+=1
            if BingocountR ==3:
                check+=1
    BingocountR = 0
for i in range(3):
    for j in range(3):
        if ArrayBingo[i][j]==1:
            BingocountG+=1
            if BingocountG ==3:
                check+=1
    BingocountG = 0
if (ArrayBingo[0][0] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][2] == 1) or (ArrayBingo[0][2] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][0] == 1):
    check += 1
if check>0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
bingo = []
is_bingo = False
for i in range(3):
    bingo.append(list(map(int, input().split())))
for i in range(3):
    bingo.append([bingo[j][i] for j in range(3)])
bingo.append([bingo[i][i] for i in range(3)])
bingo.append([bingo[i][2-i] for i in range(3)])
n = int(input())
result = set()
for i in range(n):
    result.add(int(input()))
for i in bingo:
    if set(i).issubset(result):
        print('Yes')
        is_bingo = True
        break
if not is_bingo:
    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)]

for x in b:
    for i,a in enumerate(A):
        if x in a:
            A[i][a.index(x)] = 0
for i in range(3):
    if A[i][0]+A[i][1]+A[i][2] == 0 or A[0][i]+A[1][i]+A[2][i] == 0:
        print("Yes")
        exit()

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

Submission status: Accepted

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


BINGO=[{0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}]

hole=set()
for num in b:
    for i in range(9):
        if num==A[i]:
            hole.add(i)

for tri in BINGO:

    if tri <= hole:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

a = [[0]*3 for _ in range(3)]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
a[2] = list(map(int, input().split()))

n = int(input())
f = [[False]*3 for _ in range(3)]
for _ in range(n):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j] == b:
        f[i][j] = True

for i in range(3):
  if (f[i][0] and f[i][1] and f[i][2]):
    print("Yes")
    sys.exit()
  if (f[0][i] and f[1][i] and f[2][i]):
    print("Yes")
    sys.exit()
if ((f[0][0] and f[1][1] and f[2][2]) or (f[0][2] and f[1][1] and f[2][0])):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
A = []
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
A.append(A_1)
A.append(A_2)
A.append(A_3)

N = int(input())
b = []

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

c = [[0,0,0],[0,0,0],[0,0,0]]
for j in range(N):
    for p in range(3):
        for l in range(3):
            if b[j] == A[p][l]:
                c[p][l] = 1

check = 0
for d in range(N):
    for o in range(3):
        if c[o][0] == 1 and c[o][1] == 1 and c[o][2] == 1:
            check += 1
            break

    for g in range(3):
        if c[0][g] == 1 and c[1][g] == 1 and c[2][g] == 1:
            check += 1
            break

    if c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1:
        check += 1
    if c[0][2] == 1 and c[1][1] == 1 and c[2][0] == 1:
        check += 1
    if check != 0:
        break

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

Submission status: Accepted

Solution code:
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()

loopin=input()

A11,A12,A13,A21,A22,A23,A31,A32,A33=0,0,0,0,0,0,0,0,0


for x in range(int(loopin)):
	bingo = input()
	if bingo==a:
		A11=1
	elif bingo==b:
		A12=1	
	elif bingo==c:
		A13=1	
	elif bingo==d:
		A21=1	
	elif bingo==e:
		A22=1	
	elif bingo==f:
		A23=1	
	elif bingo==g:
		A31=1	
	elif bingo==h:
		A32=1
	elif bingo==i:
		A33=1


if (A11+A12+A13)==3:
	print("Yes")
elif (A21+A22+A23)==3:
	print("Yes")
elif (A31+A32+A33)==3:
	print("Yes")
elif (A11+A21+A31)==3:
	print("Yes")
elif (A12+A22+A32)==3:
	print("Yes")
elif (A13+A23+A33)==3:
	print("Yes")
elif (A11+A22+A33)==3:
	print("Yes")
elif (A13+A22+A31)==3:
	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()))
c = [[0,0,0],
     [0,0,0],
     [0,0,0]]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j] = 1

flag = 0
for i in range(3):
    if c[i] == [1,1,1]:
        flag = 1
for i in range(3):
    if c[0][i] == c[1][i] == c[2][i] == 1:
        flag = 1
if c[0][0] == c[1][1] == c[2][2] == 1:
    flag = 1
if c[2][0] == c[1][1] == c[0][2] == 1:
    flag = 1

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

Submission status: Accepted

Solution code:
A = []
for i in range(3):
    a1,a2,a3 = list(map(int,input().split()))
    Ai = [a1,a2,a3]
    A.extend(Ai)
n = int(input())
ana = []
for i in range(n):
    b = int(input())
    if b in A:
        idx = A.index(b)
        ana.append(idx)
atari = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
judje = False
for i in range(len(atari)):
    if (atari[i][0] in ana and atari[i][1] in ana)  and atari[i][2] in ana:
        judje = True
        break
if judje == True:    
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Sat Mar 28 10:36:41 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

a = nan(3)
d = [[0] * 3 for _ in range(3)]
n = ni()
b = nin(n)
dic = defaultdict(int)

for i in range(n):
    dic[b[i]] += 1

for i in range(3):
    for j in range(3):
        d[i][j] = dic[a[i][j]] >= 1

flag = False
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[i][j]
    if cnt == 3:
        flag = True

for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[j][i]
    if cnt == 3:
        flag = True

cnt_r = 0
cnt_l = 0
for j in range(3):
    cnt_r += d[j][j]
    cnt_l += d[j][3 - j - 1]
if cnt_r == 3 or cnt_l == 3:
    flag = True

print("Yes" if flag else "No")

Submission status: Accepted

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

def check(card):
    if (card[0][0] == card[0][1] == card[0][2] == 'x') or (card[1][0] == card[1][1] == card[1][2] == 'x') or (card[2][0] == card[2][1] == card[2][2] == 'x'):
        return 'Yes'
    elif (card[0][0] == card[1][0] == card[2][0] == 'x') or (card[0][1] == card[1][1] == card[2][1] == 'x') or (card[0][2] == card[1][2] == card[2][2] == 'x'):
        return 'Yes'
    elif (card[0][0] == card[1][1] == card[2][2] == 'x') or (card[0][2] == card[1][1] == card[2][0] == 'x'):
        return 'Yes'
    else:
        return 'No'

for a in number:
    for b in bingo:
        for c in b:
            if a == c:
                bingo[bingo.index(b)][bingo[bingo.index(b)].index(c)] = 'x'

print(check(bingo))

Submission status: Accepted

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

n = int(input())

def bg(a):
    f = False
    for i in range(3):
        t = 0
        for j in range(3):
            t += a[i][j]
        if t== 3:
            f = True

    for i in range(3):
        t = 0
        for j in range(3):
            t += a[j][i]
        if t== 3:
            f = True
    t = 0
    s = 0
    for i in range(3):
        t += a[i][i]
        s += a[i][-i-1]
    if t==3 or s ==3:
        f = True
    return f
ma = [[0]*3 for i in range(3)]
for c in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                ma[i][j] = 1
if bg(ma):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# B - Bingo

import numpy as np

A = np.zeros((3,3), dtype=np.int64)

for i in range(3):
    A[i] = [int(x) for x in input().split()]

N = int(input())

for _ in range(N):
    b = int(input())
    A = np.where(A==b, 0, A)

if sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 or \
    sum(A[:,0])==0 or sum(A[:,1])==0 or sum(A[:,2])==0 or \
    A[0,0]+A[1,1]+A[2,2]==0 or \
    A[2,0]+A[1,1]+A[0,2]==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
List = [list(map(int,input().split())) for i in range (3)]
N = int(input())
Number = [int(input()) for i in range (N)]
a = 'No'
for k in range(0,3):
    for j in range(0,3):
        for i in range(0,N):
            if Number[i]== List[k][j]:
                List[k][j]=0
            
if List[0] == [0,0,0] or List[1] == [0,0,0] or List[2]== [0,0,0]:
    a = 'Yes'
for m in range(0,3):
    if List[0][m] == 0 and List[1][m] == 0 and List[2][m]==0:
        a ='Yes'
if List[0][0]==0 and List[1][1] == 0 and List[2][2]==0:
    a = 'Yes'
if List[0][2]==0 and List[1][1] == 0 and List[2][0]==0:
    a = 'Yes'
print (a)

Submission status: Accepted

Solution code:
a = []
b = [0] * 9

def match(n):
    if n in a:
        b[a.index(n)] += 1

def is_bingo(l, m, n):
    return b[l]*b[m]*b[n]

line = [[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 i in range(3):
    a += [int(i) for i in input().split()]
n = int(input())
for i in range(n):
    match(int(input()))
print('Yes' if any((is_bingo(line[i][0], line[i][1], line[i][2]) for i in range(8))) else 'No')

Submission status: Accepted

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

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

Bingo = [[False]*3 for _ in range(3)]
for k in range(9):
    i = k // 3
    j = k % 3
    for b in B:
        if A[i][j] == b:
            Bingo[i][j] = True

for i in range(3):
    if Bingo[i][1] and Bingo[i][2] and Bingo[i][0] == True:
        print("Yes")
        exit()
    if Bingo[1][i] and Bingo[2][i] and Bingo[0][i] == True:
        print("Yes")
        exit()

if Bingo[1][1] and Bingo[2][2] and Bingo[0][0] == True:
    print("Yes")
    exit()
if Bingo[0][2] and Bingo[1][1] and Bingo[2][0] == True:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
table_1 = input().split()
table_2 = input().split()
table_3 = input().split()
bingo_card = table_1 + table_2 + table_3

N = int(input())

for _ in range(N):
    b = str(int(input()))
    if b in bingo_card:
        bingo_card[bingo_card.index(b)] = True
        
if bingo_card[0] == bingo_card[1] == bingo_card[2]:
    print('Yes')
elif bingo_card[3] == bingo_card[4] == bingo_card[5]:
    print('Yes')
elif bingo_card[6] == bingo_card[7] == bingo_card[8]:
    print('Yes')
elif bingo_card[0] == bingo_card[3] == bingo_card[6]:
    print('Yes')
elif bingo_card[1] == bingo_card[4] == bingo_card[7]:
    print('Yes')
elif bingo_card[2] == bingo_card[5] == bingo_card[8]:
    print('Yes')
elif bingo_card[0] == bingo_card[4] == bingo_card[8]:
    print('Yes')
elif bingo_card[2] == bingo_card[4] == bingo_card[6]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
bingos = [(A11, A12, A13), (A21, A22, A23), (A31, A32, A33), (A11, A21, A31), (A12, A22, A32), (A13, A23, A33), (A11, A22, A33), (A13, A22, A31)]
bingo_cnt = [0,0,0,0,0,0,0,0]
N = int(input())
for i in range(N):
  b_temp = int(input())
  for j in range(len(bingos)):
    if b_temp in bingos[j]:
      bingo_cnt[j] += 1
if max(bingo_cnt) == 3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s,a=',036,048,246,258,345,678,',open(0).read().split()
for i in a[9:]:s=s.replace(str(a.index(i)),'')
print('NYoe s'[',,'in s::2])

Submission status: Accepted

Solution code:
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
N = int(input())
b = [int(input()) for i in range(N)]
cor = [[0 for _ in range(3)] for _ in range(3)]
ans = 'No'

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == A[j][k]:
                cor[j][k] = 1

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

if cor[0][0] == 1 and cor[1][1] == 1 and cor[2][2] == 1:
    ans = 'Yes'
if cor[0][2] == 1 and cor[1][1] == 1 and cor[2][0] == 1:
    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())
for i in range(N):
    b=int(input())
    for ii in range(3):
        for iii in range(3):
            if A[ii][iii]==b:
                A[ii][iii]=0

flag=False
for i in range(3):
    if A[i][:]==[0,0,0]:
        flag=True
    elif A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        flag=True
    elif A[1][1]==0:
        if A[0][2]==0 and A[2][0]==0:
            flag=True
        elif A[0][0]==0 and A[2][2]==0:
            flag=True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
number = []
result = "No"

for i in range(3):
	for n in input().split():
		n = int(n)
		number.append(n)

bingo = [None for _ in range(9)]

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


for i in range(3):
	if bingo[3*i] == bingo[3*i+1] and bingo[3*i+1] == bingo[3*i+2] and bingo[3*i] == True:
		result = "Yes"

for i in range(3):
	if bingo[i] == bingo[3+i] and bingo[3+i] == bingo[6+i] and bingo[i] == True:
		result = "Yes"

if bingo[0] == bingo[4] and bingo[4] == bingo[8] and bingo[0] == True:
	result = "Yes"

if bingo[2] == bingo[4] and bingo[4] == bingo[6] and bingo[2] == True:
	result = "Yes"

print(result)

Submission status: Accepted

Solution code:
import itertools

A = [input().split() for _ in range(3)]
A = list(itertools.chain.from_iterable(A))
N = int(input())
B = [input() for _ in range(N)]

l = [a in B for a in A]
if l[0] == l[1] == l[2] == True:
    print("Yes")
elif l[3] == l[4] == l[5] == True:
    print("Yes")
elif l[6] == l[7] == l[8] == True:
    print("Yes")
elif l[0] == l[3] == l[6] == True:
    print("Yes")
elif l[1] == l[4] == l[7] == True:
    print("Yes")
elif l[2] == l[5] == l[8] == True:
    print("Yes")
elif l[0] == l[4] == l[8] == True:
    print("Yes")
elif l[2] == l[4] == l[6] == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = [[int(i) for i in input().split()] for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
check = 0

for num in b:
    for i in range(3):
        for j in range(3):
            if S[i][j] == num:
                S[i][j] = '*'

if len(set(S[0])) == 1 or len(set(S[1])) == 1 or len(set(S[2])) == 1:
    check = 1

for i in range(3):
    cnt = 0
    for j in range(3):
        if S[j][i] == '*':
            cnt += 1
    if cnt == 3:
        check = 1

if S[0][0] == S[1][1] == S[2][2] == '*' or S[0][2] == S[1][1] == S[2][0] == '*':
    check = 1

if check == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = list()

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

A.append(A1)
A.append(A2)
A.append(A3)

N = int(input())

b = list()
for i in range(N):
    b.append(int(input()))

for x in range(N):
    for y in range(3):
        for z in range(3):
            if b[x] == A[y][z]:
                A[y][z] = 101


for i in range(3):
    counter = 0
    counter3 = 0
    for j in range(3):
        if A[i][j] == 101:
            counter += 1
        if A[j][i] == 101:
            counter3 += 1
        if counter == 3 or counter3 == 3:
            break
    if counter == 3 or counter3 == 3:
        break
if counter == 3 or counter3 == 3:
    print('Yes')

else:
    counter1 = 0
    for i in range(3):
        if A[i][i] == 101:
            counter1 += 1
    if counter1 == 3:
        print('Yes')
    else:
        counter2 = 0
        for i in range(3):
            if A[i][2-i] == 101:
                counter2 += 1
        if counter2 == 3:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

Solution code:
def check(A):
	if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
		return 1
	elif A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
		return 1
	for i in range(3):
		if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
			return 1
		elif A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
			return 1
	return 0
			


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

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

if check(A):
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

a = []
a.append(list(input().split()))
a.append(list(input().split()))
a.append(list(input().split()))

def kezuru(b):
    for i in range(len(a)):
        for j in range(len(a[i])):
            if b == a[i][j]:
                a[i][j] = '*'
        

n = int(input())
for i in range(n):
    b = input()
    kezuru(b)
    
def check():
    for i in range(3):
        if a[i][0] == a[i][1] and a[i][0] == a[i][2]:
            return 'Yes'
    for i in range(3):
        if a[0][i] == a[1][i] and a[0][i] == a[2][i]:
            return 'Yes'
    if a[0][0] == a[1][1] and a[0][0] == a[2][2]:
        return 'Yes'
    if a[0][2] == a[1][1] and a[0][2] == a[2][0]:
        return 'Yes'
    return 'No'
    
print(check())

Submission status: Accepted

Solution code:
#ABC157.B
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)]
if (A1[0] in b)and (A1[1]in b)and (A1[2] in b):
    print('Yes')
elif (A2[0]in b)and(A2[1] in b)and(A2[2]in b):
    print('Yes')
elif (A3[0]in b)and(A3[1]in b)and (A3[2]in b):
    print('Yes')
elif (A1[0]in b)and(A2[0]in b)and(A3[0]in b):
    print('Yes')
elif (A1[1]in b)and (A2[1]in b)and(A3[1]in b):
    print('Yes')
elif (A1[2] in b)and (A2[2]in b)and(A3[2]in b):
    print('Yes')
elif (A1[0]in b)and (A2[1]in b)and(A3[2]in b):
    print('Yes')
elif (A1[2]in b)and (A2[1]in b)and(A3[0]in b):
    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)]
B = [[0,0,0],[0,0,0],[0,0,0]]

ans = 'No'
for i, row in enumerate(A):
    for j, value in enumerate(row):
        if value in b:
            B[i][j] = 1
#print(B)
if B[0][0]==B[0][1]==B[0][2]==1 or B[1][0]==B[1][1]==B[1][2]==1 or B[2][0]==B[2][1]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][0]==B[2][0]==1 or B[0][1]==B[1][1]==B[2][1]==1 or B[0][2]==B[1][2]==B[2][2]==1:
    ans = 'Yes'
elif B[0][0]==B[1][1]==B[2][2]==1 or B[0][2]==B[1][1]==B[2][0]==1:
    ans = 'Yes'
print(ans)