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_list=[]
a_list+=(list(map(int,input().split())))
a_list+=(list(map(int,input().split())))
a_list+=(list(map(int,input().split())))

N=int(input())

b_list=[False]*9
for i in range(N):
    b=int(input())
    for j,a in enumerate(a_list):
        if a==b:
            b_list[j]=True

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

ans="No"
for k in kumi:
    if b_list[k[0]]*b_list[k[1]]*b_list[k[2]]:
        ans="Yes"

print(ans)

Submission status: Accepted

Solution code:
#n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))

da = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for k in range(3):
    for i in range(3):
        for j in range(n):
            if(da[k][i] == b[j]):
                da[k][i] = 0
                break
ju = False
for i in range(3):
    if(da[i][0] == 0 and da[i][1] == 0 and da[i][2] == 0):
        ju = True
    if(da[1][i] == 0 and da[2][i] == 0 and da[0][i] == 0):
        ju = True
if da[0][0] == 0 and da[1][1] == 0 and da[2][2] == 0:
    ju = True
if da[0][2] == 0 and da[1][1] == 0 and da[2][0] == 0:
    ju = True

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

Submission status: Accepted

Solution code:
ls = []
for i in range(3):
    a = list(map(int,input().split()))
    ls.append(a)
lb = []
n = int(input())
for i in range(n):
    b = int(input())
    lb.append(b)
    
for i in range(n):
    for j in range(3):
        for k in range(3):
            if lb[i] == ls[j][k]:
                ls[j][k] = "#"
if ls[0][0] == "#" and ls[1][0] == "#" and ls[2][0] == "#":
    print("Yes")
elif ls[0][1] == "#" and ls[1][1] == "#" and ls[2][1] == "#":
    print("Yes")
elif ls[0][2] == "#" and ls[1][2] == "#" and ls[2][2] == "#":
    print("Yes")
elif ls[0][0] == "#" and ls[0][1] == "#" and ls[0][2] == "#":
    print("Yes")
elif ls[1][0] == "#" and ls[1][1] == "#" and ls[1][2] == "#":
    print("Yes")
elif ls[2][0] == "#" and ls[2][1] == "#" and ls[2][2] == "#":
    print("Yes")
elif ls[0][0] == "#" and ls[1][1] == "#" and ls[2][2] == "#":
    print("Yes")
elif ls[0][2] == "#" and ls[1][1] == "#" and ls[2][0] == "#":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def read():
    A = list()
    for i in range(3):
        a = list(map(int, input().strip().split()))
        A.append(a)
    N = int(input().strip())
    B = list()
    for i in range(N):
        b = int(input().strip())
        B.append(b)
    return A, N, B

def solve(A, N, B):
    lines = [
        [(0, 0), (0, 1), (0, 2)],
        [(1, 0), (1, 1), (1, 2)],
        [(2, 0), (2, 1), (2, 2)],
        [(0, 0), (1, 0), (2, 0)],
        [(0, 1), (1, 1), (2, 1)],
        [(0, 2), (1, 2), (2, 2)],
        [(0, 0), (1, 1), (2, 2)],
        [(0, 2), (1, 1), (2, 0)]
    ]
    C = [[False for j in range(3)] for i in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    C[i][j] = True
    for line in lines:
        is_bingo = True
        for r, c in line:
            if not C[r][c]:
                is_bingo = False
        if is_bingo:
            return 'Yes'
    return 'No'


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

Submission status: Accepted

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    A = [[] for _ in range(3)]
    for i in range(3):
        A[i] = lr()
    N = ir()
    card = [[False, False, False] for _ in range(3)]
    for i in range(N):
        b = ir()
        for j in range(3):
            for k in range(3):
                if A[j][k] == b:
                    card[j][k] = True
    for i in range(3):
        if card[i] == [True, True, True]:
            print('Yes')
            return
    for i in range(3):
        if card[0][i] == True and card[1][i] == True and card[2][i] == True:
            print('Yes')
            return
    if card[0][0] == True and card[1][1] == True and card[2][2] == True:
        print('Yes')
        return
    if card[2][0] == True and card[1][1] == True and card[0][2] == True:
        print('Yes')
        return
    print('No')
resolve()

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = [lr() for _ in range(3)]
N = ir()
bool = [[False] * 3 for _ in range(3)]
for _ in range(N):
    b = ir()
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                bool[i][j] = True

answer = False
for i in range(3):
    if sum(bool[i]) == 3:
        answer = True
for j in range(3):
    cur = 0
    for i in range(3):
        if bool[i][j] == True:
            cur += 1
    if cur == 3:
        answer = True

if bool[0][0] + bool[1][1] + bool[2][2] == 3:
    answer = True
if bool[2][0] + bool[1][1] + bool[2][0] == 3:
    answer = True

print('Yes' if answer else 'No')

Submission status: Accepted

Solution code:
A_list1 = list(map(int, input().split()))
A_list2 = list(map(int, input().split()))
A_list3 = list(map(int, input().split()))

bingo = [A_list1, A_list2, A_list3, [A_list1[0], A_list2[1], A_list3[2]], [A_list1[2], A_list2[1], A_list3[0]], [A_list1[0], A_list2[0], A_list3[0]], [A_list1[1], A_list2[1], A_list3[1]], [A_list1[2], A_list2[2], A_list3[2]]]

N = int(input())

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

ans = "No"
for b in bingo:
    c = 0
    for B in b:
        if B in b_list:
            c += 1
    if c == 3:
        ans = "Yes"
        break

print(ans)

Submission status: Accepted

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a = []
for i in range(3):
    a.append(inl())
b = [[0]*3 for i in range(3)]
n = inn()
for t in range(n):
    x = inn()
    for i in range(3):
        for j in range(3):
            if a[i][j]==x:
                b[i][j] = 1
if sum(b[0])==3 or \
       sum(b[1])==3 or \
       sum(b[2])==3 or \
       b[0][0]+b[1][0]+b[2][0]==3 or \
       b[0][1]+b[1][1]+b[2][1]==3 or \
       b[0][2]+b[1][2]+b[2][2]==3 or \
       b[0][0]+b[1][1]+b[2][2]==3 or \
       b[0][2]+b[1][1]+b[2][0]==3:
        print('Yes')
else:
        print('No')

Submission status: Accepted

Solution code:
import sys
a = []
bingo = [[0 for _ in range(3)] for _ in range(3)]
for _ in range(3):
  a_dash = list(map(int,input().split()))
  a.append(a_dash)

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

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

if bingo[0][0] == 1 and bingo[0][1] == 1 and bingo[0][2] == 1:
  print('Yes')
  sys.exit()
elif bingo[1][0] == 1 and bingo[1][1] == 1 and bingo[1][2] == 1:
  print('Yes')
  sys.exit()
elif bingo[2][0] == 1 and bingo[2][1] == 1 and bingo[2][2] == 1:
  print('Yes')
  sys.exit()
elif bingo[0][0] == 1 and bingo[1][0] == 1 and bingo[2][0] == 1:
  print('Yes')
  sys.exit()
elif bingo[0][1] == 1 and bingo[1][1] == 1 and bingo[2][1] == 1:
  print('Yes')
  sys.exit()
elif bingo[0][2] == 1 and bingo[1][2] == 1 and bingo[2][2] == 1:
  print('Yes')
  sys.exit()
elif bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
  print('Yes')
  sys.exit()
elif bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
  print('Yes')
  sys.exit()
else:
  print('No')

Submission status: Accepted

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

for i in range(n):
    m = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == m:
                B[j][k] = True

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

if B[0][0] and B[1][1] and B[2][2]:
    print("Yes")
    exit()
if B[0][2] and B[1][1] and B[2][0]:
    print("Yes")
    exit()

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=[int(input()) for i in range(n)]
result=0
if (a_1[0] in b) and (a_1[1] in b) and (a_1[2] in b):
  result=1
if (a_2[0] in b) and (a_2[1] in b) and (a_2[2] in b):
  result=1
if (a_3[0] in b) and (a_3[1] in b) and (a_3[2] in b):
  result=1
if (a_1[0] in b) and (a_2[0] in b) and (a_3[0] in b):
  result=1
if (a_1[1] in b) and (a_2[1] in b) and (a_3[1] in b):
  result=1
if (a_1[2] in b) and (a_2[2] in b) and (a_3[2] in b):
  result=1
if (a_1[0] in b) and (a_2[1] in b) and (a_3[2] in b):
  result=1
if (a_1[2] in b) and (a_2[1] in b) and (a_3[0] in b):
  result=1
  
if result==1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a_ls1 = list(map(int,input().split()))
a_ls2 = list(map(int,input().split()))
a_ls3 = list(map(int,input().split()))
n = int(input())
b_ls = [int(input()) for _  in range(n)]

a_ls4 = [a_ls1[0],a_ls2[0],a_ls3[0]]
a_ls5 = [a_ls1[1],a_ls2[1],a_ls3[1]]
a_ls6 = [a_ls1[2],a_ls2[2],a_ls3[2]]
a_ls7 = [a_ls1[0],a_ls2[1],a_ls3[2]]
a_ls8 = [a_ls1[2],a_ls2[1],a_ls3[0]]
lss = [a_ls1,a_ls2,a_ls3,a_ls4,a_ls5,a_ls6,a_ls7,a_ls8]

for i in b_ls:
    for j in lss:
        for k in j:
            if i ==k:
                j.pop(j.index(k))
for i in lss:
    if i ==[]:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    A = [list(iim()) for i in range(3)]
    N = int(input())
    B = set(int(input()) for i in range(N))

    C = [[i in B for i in aa] for aa in A]

    #print(A)
    #print(B)
    #print(C)

    def f():
        for i in range(3):
            for j in range(3):
                if not C[i][j]:
                    break
            else:
                return True
            for j in range(3):
                if not C[j][i]:
                    break
            else:
                return True
        for i in range(3):
            if not C[i][i]:
                break
        else:
            return True
        for i in range(3):
            if not C[i][2-i]:
                break
        else:
            return True
        return False

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


if __name__ == "__main__":
    resolve()

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)]
X = [[0 for _ in range(3)] for _ in range(3)]
for n in range(N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == B[n]:
                X[i][j] = 1
tate = any([all([X[i][j] for j in range(3)]) for i in range(3)])
yoko = any([all([X[i][j] for i in range(3)]) for j in range(3)])
nana = all([X[i][i] for i in range(3)]) or all([X[i][2 - i] for i in range(3)])
if tate or yoko or nana:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A = [list(map(int, (readline().split()))) for _ in range(3)]
N = int(readline().decode())
B = [int(readline().decode().rstrip()) for _ in range(N)]

card = [[False] * 3 for _ in range(3)]

ans = "No"

for b in B:
    for r in range(3):
        for c in range(3):
            if b == A[r][c]:
                card[r][c] = True

for i in range(3):
    if card[i][0] == card[i][1] == card[i][2] == True:
        ans = "Yes"
    if card[0][i] == card[1][i] == card[2][i] == True:
        ans = "Yes"
if card[0][0] == card[1][1] == card[2][2] == True:
    ans = "Yes"
if card[0][2] == card[1][1] == card[2][0] == True:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    a = list()
    for i in range(3):
        a.append(list(map(int, input().split())))
    n = int(input())
    for i in range(n):
        tmp = int(input())
        for j in range(3):
            for k in range(3):
                if tmp == a[j][k]:
                    a[j][k] = 0

    # 横の判定
    for i in range(3):
        if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0:
            print('Yes')
            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')

Submission status: Accepted

Solution code:
def check_bingo(s):
    for l in s:
        if all(l):
            return True

    for i in range(3):
        if s[0][i] and s[1][i] and s[2][i]:
            return True

    if s[0][0] and s[1][1] and s[2][2]:
        return True
    
    if s[0][2] and s[1][1] and s[2][0]:
        return True

    return False

a = list()
sheet = list()
for i in range(3):
    a.append(list(map(int, input().split())))
    sheet.append([False]*3)
    
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                sheet[j][k] = True

if check_bingo(sheet):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    hit = [0] * 9
    for i in range(n):
        b = int(input())
        for j in range(9):
            if a[j] == b:
                hit[j] = 1

    ans = 'No'
    if hit[0] + hit[1] + hit[2] == 3:
        ans = 'Yes'
    if hit[3] + hit[4] + hit[5] == 3:
        ans = 'Yes'
    if hit[6] + hit[7] + hit[8] == 3:
        ans = 'Yes'
    if hit[0] + hit[3] + hit[6] == 3:
        ans = 'Yes'
    if hit[1] + hit[4] + hit[7] == 3:
        ans = 'Yes'
    if hit[2] + hit[5] + hit[8] == 3:
        ans = 'Yes'
    if hit[0] + hit[4] + hit[8] == 3:
        ans = 'Yes'
    if hit[2] + hit[4] + hit[6] == 3:
        ans = 'Yes'

    print(ans)


main()

Submission status: Accepted

Solution code:
a = [[0]*3 for _ in range(3)]
f = [[0]*3 for _ in range(3)]

for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
ans = "No"

for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                f[j][k] = 1
    
for l in range(3):
    if f[l][0] == 1 and f[l][1] == 1 and f[l][2] == 1:
        ans = "Yes"
    elif f[0][l] == 1 and f[2][l] == 1 and f[1][l] == 1:
        ans = "Yes"
    elif f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
        ans = "Yes"
    elif f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
        ans = "Yes"
        
print(ans)

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [[0] * 3 for i in range(3)]
for i in range(n):
  num = int(input())
  for i in range(3):
    for j in range(3):
      if num == a[i][j]:
        b[i][j] = 1
for i in range(3):
  if b[i][0] == b[i][1] == b[i][2] == 1:
    print("Yes")
    exit()
  if b[0][i] == b[1][i] == b[2][i] == 1:
    print("Yes")
    exit()
if b[0][0] == b[1][1] == b[2][2] == 1:
  print("Yes")
  exit()
if b[0][2] == b[1][1] == b[2][0] == 1:
  print("Yes")
  exit()
print("No")

Submission status: Accepted

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

for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = -1

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

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

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

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

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

arr=[[False]*3 for _ in range(3)]

for x in b:
  for i in range(3):
    for j in range(3):
      if x==a[i][j]:
        arr[i][j]=True

for i in range(3):
  if all(arr[i]) or all([arr[j][i] for j in range(3)]):
    print('Yes')
    exit()
if all([arr[i][i] for i in range(3)]) or all([arr[i][2-i] for i in range(3)]):
  print('Yes')
  exit()
print('No')

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    A = [LIST() for i in range(3)]
    N = INT()

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

        flag = False
        if A[0][0] + A[0][1] + A[0][2] == 0:
            flag = True
        if A[1][0] + A[1][1] + A[1][2] == 0:
            flag = True
        if A[2][0] + A[2][1] + A[2][2] == 0:
            flag = True
        if A[0][0] + A[1][0] + A[2][0] == 0:
            flag = True
        if A[0][1] + A[1][1] + A[2][1] == 0:
            flag = True
        if A[0][2] + A[1][2] + A[2][2] == 0:
            flag = True
        if A[0][0] + A[1][1] + A[2][2] == 0:
            flag = True
        if A[2][0] + A[1][1] + A[0][2] == 0:
            flag = True

        if flag:
            print("Yes")
            sys.exit()

    print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

N = int(input())
List=[int(input()) for i in range(N)]

for i in List:
  if i in Bingo[0]:
    a = Bingo[0].index(i)
    Bingo[0][a] = 0
  if i in Bingo[1]:
    a = Bingo[1].index(i)
    Bingo[1][a] = 0
  if i in Bingo[2]:
    a = Bingo[2].index(i)
    Bingo[2][a] = 0
    
ans = "No"

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

Submission status: Accepted

Solution code:
A = []
for _ in range(3):
    a1 = list(map(int, input().split()))
    A.append(a1)
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0
s = 0
for i in range(3):
    if sum(A[i]) == 0:
        s = 1
for i in range(3):
    if A[0][i] + A[1][i] + A[2][i] == 0:
        s = 1
if A[0][0] + A[1][1] + A[2][2] == 0:
    s = 1
if A[0][2] + A[1][1] + A[2][0] == 0:
    s = 1
    
if s == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
c = []
for i in range(3):
    l = [int(x) for x in input().split()]
    c+=l
n = int(input())
che = [False]*9
ans = "No"
for i in range(n):
    b = int(input())
    for j in range(9):
        if c[j] == b:
            che[j] = True
#bingo check
for i in range(3):
    if che[i] and che[i+3] and che[i+6]:
        ans = "Yes"
        break
    elif che[i*3] and che[i*3 +1] and che[i*3 +2]:
        ans = "Yes"
        break
if ans == "No":
    if che[0] and che[4] and che[8]:
        ans = "Yes"
    elif che[2] and che[4] and che[6]:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
p = [input().split() for i in range(3)]
N = int(input())
bs = [input() for i in range(N)]

flag = False
if p[0][0] in bs and p[0][1] in bs and p[0][2] in bs:
  flag = True
if p[1][0] in bs and p[1][1] in bs and p[1][2] in bs:
  flag = True
if p[2][0] in bs and p[2][1] in bs and p[2][2] in bs:
  flag = True
if p[0][0] in bs and p[1][0] in bs and p[2][0] in bs:
  flag = True
if p[0][1] in bs and p[1][1] in bs and p[2][1] in bs:
  flag = True
if p[0][2] in bs and p[1][2] in bs and p[2][2] in bs:
  flag = True
if p[0][0] in bs and p[1][1] in bs and p[2][2] in bs:
  flag = True
if p[0][2] in bs and p[1][1] in bs and p[2][0] in bs:
  flag = True

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

Submission status: Accepted

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

for i in range(3):
    a1, a2, a3 = map(int, input().split())
    A[i][0] = a1
    A[i][1] = a2
    A[i][2] = a3
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        print("Yes")
        exit()
    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 _ in range(3):
    a = list(map(int,input().split()))
    A.append(a)
N = int(input())
Y = []
for _ in range(N):
    y = int(input())
    Y.append(y)
ans = 0
for i in range(3):
    if A[i][0] in Y and A[i][1] in Y and A[i][2] in Y :
        ans = 1
for i in range(3):
    if A[0][i] in Y and A[1][i] in Y and A[2][i] in Y :
        ans = 1
if A[0][0] in Y and A[1][1] in Y and A[2][2] in Y :
    ans = 1
if A[2][0] in Y and A[1][1] in Y and A[0][2] in Y :
    ans = 1
if ans == 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=[]
for _ in range(N):
    b.append( int(input()) )
A1_check = [False, False, False]
A2_check = [False, False, False]
A3_check = [False, False, False]
for ii in range(3):
    for b_ in b:
        if A1[ii]==b_:
            A1_check[ii]=True
for ii in range(3):
    for b_ in b:
        if A2[ii]==b_:
            A2_check[ii]=True
for ii in range(3):
    for b_ in b:
        if A3[ii]==b_:
            A3_check[ii]=True
if A1_check[0]*A1_check[1]*A1_check[2]==True or \
   A2_check[0]*A2_check[1]*A2_check[2]==True or \
   A3_check[0]*A3_check[1]*A3_check[2]==True or \
   A1_check[0]*A2_check[0]*A3_check[0]==True or \
   A1_check[1]*A2_check[1]*A3_check[1]==True or \
   A1_check[2]*A2_check[2]*A3_check[2]==True or \
   A1_check[0]*A2_check[1]*A3_check[2]==True or \
   A1_check[2]*A2_check[1]*A3_check[0]==True:
    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())

for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b:
            a1[j]=0
        if a2[j]==b:
            a2[j]=0
        if a3[j]==b:
            a3[j]=0

if a1[0]+a1[1]+a1[2]==0:
    print("Yes")
    exit()
if a2[0]+a2[1]+a2[2]==0:
    print("Yes")
    exit()
if a3[0]+a3[1]+a3[2]==0:
    print("Yes")
    exit()
if a1[0]+a2[0]+a3[0]==0:
    print("Yes")
    exit()
if a1[1]+a2[1]+a3[1]==0:
    print("Yes")
    exit()
if a1[2]+a2[2]+a3[2]==0:
    print("Yes")
    exit()
if a1[0]+a2[1]+a3[2]==0:
    print("Yes")
    exit()
if a1[2]+a2[1]+a3[0]==0:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
hyo = [list(map(int,input().split())) for i in range(3)]
N = int(input())
target = [int(input()) for i in range(N)]
#print(hyo,N,target)

answer = []
for h in hyo:
    answer.append(h)
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(hyo[j][i])
    answer.append(tmp)
answer.append([hyo[0][0],hyo[1][1],hyo[2][2]])
answer.append([hyo[0][2],hyo[1][1],hyo[2][0]])

for a in answer:
    tmp = set(target) & set(a)
    if len(tmp) == 3:
        print('Yes')
        exit(0)
print('No')

Submission status: Accepted

Solution code:
l = []

for _ in range(3):
    t = [int(x) for x in input().split()]
    l.append(t[0])
    l.append(t[1])
    l.append(t[2])
    
for _ in range(int(input())):
    t = int(input())

    for x in range(9):
        if l[x] == t:
            l[x] = 0

s = ["012", "345", "678", "036", "147", "258", "048", "246"]
flag = 0

for x in s:
    chk = 0
    for y in x:
        if l[int(y)] == 0:
            chk += 1

    if chk == 3:
        flag = 1
        break

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

Submission status: Accepted

Solution code:
a = []
for _ in range(3):
    a.extend(list(input().split()))

n = int(input())
for _ in range(n):
    k = input()
    for i in range(9):
        if a[i] == str(k):
            a[i] = 0

ans = False

if a[0] == a[1] and a[1] == a[2] and a[2] == 0:
    ans = True

if a[3] == a[4] and a[4] == a[5] and a[5] == 0:
    ans = True

if a[6] == a[7] and a[7] == a[8] and a[8] == 0:
    ans = True

if a[0] == a[3] and a[3] == a[6] and a[6] == 0:
    ans = True

if a[1] == a[4] and a[4] == a[7] and a[7] == 0:
    ans = True

if a[2] == a[5] and a[5] == a[8] and a[8] == 0:
    ans = True

if a[0] == a[4] and a[4] == a[8] and a[8] == 0:
    ans = True

if a[2] == a[4] and a[4] == a[6] and a[6] == 0:
    ans = True

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

Submission status: Accepted

Solution code:
card = [list(map(int, input().split())) for _ in range(3)]
yes_no = [False]*9
N = int(input())
for i in range(N):
  b = int(input()) 
  for j in range(9):
    j_1 = j//3
    j_2 = j%3
    if b == card[j_1][j_2]:
      yes_no[j] = True

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

Submission status: Accepted

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

for i in range(3):
    if l[i][0] in b and l[i][1] in b and l[i][2] in b :
        print("Yes")
        exit()
for j in range(3):
    if l[0][j] in b and l[1][j] in b and l[2][j] in b :
        print("Yes")
        exit()

if l[0][0] in b and l[1][1] in b and l[2][2] in b :
    print("Yes")
    exit()
if l[2][0] in b and l[1][1] in b and l[0][2] in b :
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

A = [iln() for _ in range(3)]
N = iin()
b = [iin() for _ in range(N)]

B = [[False for _ in range(3)] for _ in range(3)]

for i in range(N):
    t = b[i]
    for j in range(3):
        for k in range(3):
            if A[j][k] == t:
                B[j][k] = True

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