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:
ri = lambda S: [int(v) for v in S.split()]

S = [ri(input()) for _ in range(3)]
N = int(input())
D = set()
O = set()

def mark(A, v):
    for i in range(3):
        for j in range(3):
            if A[i][j] != 0 and A[i][j] == v:
                A[i][j] = 0
                if (i, j) in [(0, 0), (1, 1), (2,2)]:
                    D.add((i,j))
                if (i, j) in [(0, 2), (1, 1), (2, 0)]:
                    O.add((i, j))

for _ in range(N):
    b = int(input())
    mark(S, b)

R = [sum(r) for r in S]
C = [sum(r) for r in zip(*S)]



check = len(D) == 3 or len(O) == 3 or any(v == 0 for v in R) or any(v == 0 for v in C)

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

Submission status: Accepted

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

for i in b:
    for index, cow in enumerate(a):
        for index2, k in enumerate(cow):
            if i == k:
                a[index][index2] = True

for i in a:
    if i.count(True) == 3:
        print('Yes')
        exit(0)


for i in zip(*a):
    if i.count(True) == 3:
        print("Yes")
        exit(0)


temp = [a[i][i] for i in range(3)]
temp2 = [a[i][2-i] for i in range(3)]
if temp.count(True) == 3 or temp2.count(True) == 3:
    print('Yes')
    exit(0)


print('No')

Submission status: Accepted

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

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

ans = 'No'

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

if Bingo[0][0] == Bingo[1][1] == Bingo[2][2]:
    ans = 'Yes'
if Bingo[2][0] == Bingo[1][1] == Bingo[0][2]:
    ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]
result = ''

for b in B:
  if b in A1:
    a = A1.index(b)
    A1.remove(b)
    A1.insert(a, 0)
  elif b in A2:
    a = A2.index(b)
    A2.remove(b)
    A2.insert(a, 0)
  elif b in A3:
    a = A3.index(b)
    A3.remove(b)
    A3.insert(a, 0)
  else:
    pass


if A1.count(0) == 3:
  result ='y'
elif A2.count(0) == 3:
  result ='y'
elif A3.count(0) == 3:
  result ='y'

for m in range(3):
  if A1[m] == 0 and A2[m] == 0 and A3[m] == 0:
    result ='y' 
  else:
    pass


if A1[0] == 0 and A2[1] == 0 and A3[2] == 0:
  result = 'y'
elif A1[2] == 0 and A2[1] == 0 and A3[0] == 0:
  result = 'y'


if result == 'y':
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
d = {}
m = [[False]*3 for _ in range(3)]
for i in range(3):
  for j, val in enumerate(list(map(int,input().split()))):
    d[val] = (i,j)
    
N = int(input())

for _ in range(N):
  key = int(input())
  if key in d:
    i,j = d[key]
    m[i][j] = True
  
def main():
  if m[0][0] and m[1][1] and m[2][2]:
    return True
  if m[0][2] and m[1][1] and m[2][0]:
    return True
  for i in range(3):
    if m[i][0] and m[i][1] and m[i][2]:
      return True
    if m[0][i] and m[1][i] and m[2][i]:
      return True
      
  return False

ans = main()
if ans:
  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)]
num=0
for s in range(3):
    num1=0
    for t in range(3):
        if A[s][t] in B:
            num1+=1
    if num1==3:
        num+=1
for a in range(3):
    num4=0
    for b in range(3):
        if A[b][a] in B:
            num4+=1
    if num4==3:
        num+=1
num2=0
for u in range(3):
    if A[u][u] in B:
        num2+=1
if num2==3:
    num+=1
num3=0
for v in range(3):
    if A[2-v][v] in B:
        num3+=1
if num3==3:
    num+=1
if num>0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

bingo = [[0 for _ in range(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:
        bingo[i][j] = 1
        
check = False

for i in range(3):
  if 0 not in bingo[i]:
    check = True
  
for j in range(3):
  if bingo[0][j] + bingo[1][j] + bingo[2][j] == 3:
    check = True
    
if bingo[0][0] + bingo[1][1] + bingo[2][2] == 3:
  check = True

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

Submission status: Accepted

Solution code:
import numpy as np
a1 = [int(x.strip()) for x in input().split()]
a2 = [int(x.strip()) for x in input().split()]
a3 = [int(x.strip()) for x in input().split()]
a = np.array([a1,a2,a3])
n = int(input())
bingo = 0
for i in range(n):
  b = int(input())
  if b in a:
    ch = np.argwhere(a==b)
    a[ch[0][0]][ch[0][1]] = 0 #該当する文字をゼロでパンチング
sum_col = np.sum(a, axis=0)
sum_row = np.sum(a, axis=1)
bingo = np.count_nonzero(sum_col==0) + np.count_nonzero(sum_row==0)
if a[0,0]==0 and a[1,1]==0 and a[2,2]==0:
  bingo += 1
if a[2,0]==0 and a[1,1]==0 and a[0,2]==0:
  bingo += 1
if bingo > 0:
  ans = 'Yes'
else:
  ans = 'No'
print(ans)

Submission status: Accepted

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

A = list()
A.append("")
A.extend(A1)
A.extend(A2)
A.extend(A3)

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

holes = [A.index(b) for b in B if (b in A)]
bingos = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
print("Yes" if any([(len(set(holes) & set(bingo)) == 3) for bingo in bingos]) else "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()))
  
flugs = [[False] * 3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      flugs[i][j] = True
      
result = 'No'
for i in range(3):
  if all(flugs[i][:]) or all([row[i] for row in flugs]):
    result = 'Yes'
  
if all([flugs[0][0], flugs[1][1], flugs[2][2]]):
  result = 'Yes'
    
elif all([flugs[2][0], flugs[1][1], flugs[0][2]]):
  result = 'Yes'
    
print(result)

Submission status: Accepted

Solution code:
A = []
A.append(input().split())
A.append(input().split())
A.append(input().split())
N = int(input())
b = [input() for _ in range(N)]
 
# 2次元配列として処理
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True

if (A[0][0]==True and A[1][0]==True and A[2][0]==True) or (A[0][1]==True and A[1][1]==True and A[2][1]==True) or (A[0][2]==True and A[1][2]==True and A[2][2]==True) or (A[0][0]==True and A[0][1]==True and A[0][2]==True) or (A[1][0]==True and A[1][1]==True and A[1][2]==True) or (A[2][0]==True and A[2][1]==True and A[2][2]==True) or (A[0][0]==True and A[1][1]==True and A[2][2]==True) or (A[0][2]==True and A[1][1]==True and A[2][0]==True): print('Yes')
else: print('No')

Submission status: Accepted

Solution code:
a = input("").split(" ")
a = [int(aa) for aa in a]
b = input("").split(" ")
b = [int(ab) for ab in b]
c = input("").split(" ")
c = [int(ac) for ac in c]
n = int(input(""))
hav = a + b + c
val = []
for d in range(n):
    temp = int(input(""))
    val.append(temp)
tf = [0,0,0,0,0,0,0,0,0]
i = 0
for e in hav:
    if (e in val) == True:
        tf[i] = 1
    i += 1
tr = [1,1,1]
if tf[0:3] == tr:
    print("Yes")
elif tf[3:6] == tr:
    print("Yes")
elif tf[6:9] == tr:
    print("Yes")
elif (tf[0]+tf[3]+tf[6]) == 3:
    print("Yes")
elif (tf[1]+tf[4]+tf[7]) == 3:
    print("Yes")
elif (tf[2]+tf[5]+tf[8]) == 3:
    print("Yes")
elif (tf[0]+tf[4]+tf[8]) == 3:
    print("Yes")
elif (tf[2]+tf[4]+tf[6]) == 3:
    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())

D = [int(input()) for j in range(N)]
D = list(set(D))


for i in range(len(D)):
    if D[i] == A[0]:
        A[0] = -1
    elif D[i] == A[1]:
        A[1] = -1
    elif D[i] == A[2]:
        A[2] = -1
    elif D[i] == B[0]:
        B[0] = -1
    elif D[i] == B[1]:
        B[1] = -1
    elif D[i] == B[2]:
        B[2] = -1
    elif D[i] == C[0]:
        C[0] = -1
    elif D[i] == C[1]:
        C[1] = -1
    elif D[i] == C[2]:
        C[2] = -1
    else:
        continue
    



if (A[0] == -1 and A[1] == -1 and A[2] == -1)or(B[0] == -1 and B[1] == -1 and B[2] == -1)or(C[0] == -1 and C[1] == -1 and C[2] == -1)or(A[1] == -1 and B[1] == -1 and C[1] == -1)or(A[0] == -1 and B[0] == -1 and C[0] == -1)or(A[2] == -1 and B[2] == -1 and C[2] == -1)or(A[0] == -1 and B[1] == -1 and C[2] == -1)or(A[2] == -1 and B[1] == -1 and C[0] == -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())

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


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

    vertical = [_[i] for _ in A]

    if vertical == [0, 0, 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()
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()))
A = A_1 + A_2 + A_3
check = [0 for i in range(9)]
n = int(input())
for i in range(n):
  b = int(input())
  if b in A:
    check[A.index(b)] += 1
c_1 = check[0] + check[3] + check[6]
c_2 = check[1] + check[4] + check[7]
c_3 = check[2] + check[5] + check[8]
c_4 = check[0] + check[1] + check[2]
c_5 = check[3] + check[4] + check[5]
c_6 = check[6] + check[7] + check[8]
c_7 = check[0] + check[4] + check[8]
c_8 = check[2] + check[4] + check[6]
c = [c_1,c_2,c_3,c_4,c_5,c_6,c_7,c_8]
if 3 in c:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
A = []
A += input().split()
A += input().split()
A += input().split()
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  if b[i] in A:
    A[A.index(b[i])] = '.'
    
if (A[0] == '.' and A[3] == '.' and A[6] == '.') or (A[1] == '.' and A[4] == '.' and A[7] == '.') or (A[2] == '.' and A[5] == '.' and A[8] == '.') or (A[0] == '.' and A[1] == '.' and A[2] == '.') or (A[3] == '.' and A[4] == '.' and A[5] == '.') or (A[6] == '.' and A[7] == '.' and A[8] == '.') or (A[0] == '.' and A[4] == '.' and A[8] == '.') or (A[2] == '.' and A[4] == '.' and A[6] == '.'): 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()))

ans = "No"

n = int(input())

for i in range(n):
    p = int(input())
    if a1.count(p)>0:
        a1[a1.index(p)]=-1
    if a2.count(p)>0:
        a2[a2.index(p)]=-1
    if a3.count(p)>0:
        a3[a3.index(p)]=-1

if max(a1)==-1 or max(a2)==-1 or max(a3)==-1:
    ans="Yes"

if (a1[0]==-1 and a2[0]==-1 and a3[0]==-1) or (a1[1]==-1 and a2[1]==-1 and a3[1]==-1) or ((a1[2]==-1 and a2[2]==-1 and a3[2]==-1)):
    ans="Yes"

if (a1[0]==-1 and a2[1]==-1 and a3[2]==-1) or (a1[2]==-1 and a2[1]==-1 and a3[0]==-1) :
    ans="Yes"

print(ans)

Submission status: Accepted

Solution code:
A = []
memo = [-1] * 101
for i in range(3):
    a, b, c = map(int, input().split())
    memo[a] = memo[b] = memo[c] = i
    A.append([a, b, c])
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
b = set(b)
ana = [[0] * 3 for _ in range(3)]
for num in b:
    if memo[num] == -1:
        continue
    ana[memo[num]][A[memo[num]].index(num)] = 1
#斜め
if ana[0][0] == 1 and ana[1][1] == 1 and ana[2][2] == 1:
    print("Yes")
    exit()
if ana[0][2] == 1 and ana[1][1] == 1 and ana[2][0] == 1:
    print("Yes")
    exit()
#横 縦
for i in range(3):
    if ana[i][0] == 1 and ana[i][1] == 1 and ana[i][2] == 1:
        print("Yes")
        exit()
    if ana[0][i] == 1 and ana[1][i] == 1 and ana[2][i] == 1:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
A=[input().split() for _ in range(3)]
N=int(input())
B=[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 A[0][0]==A[1][1]==A[2][2] or A[0][2]==A[1][1]==A[2][0]:
  print("Yes")
  exit()

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

print('No')

Submission status: Accepted

Solution code:
A = [input().split() for _ in range(3)]
N = int(input())
B = [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 A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    print('Yes')
    exit()

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

print('No')

Submission status: Accepted

Solution code:
Card = [list(map(int, input().split())) for _ in range(3)]
Bingo = [[False]*3 for _ in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        if b in Card[j]:
            Bingo[j][Card[j].index(b)] = True
ans = False
for i in range(3):
    if all(Bingo[i][j] for j in range(3)):
        ans = True

for j in range(3):
    if Bingo[0][j] and Bingo[1][j] and Bingo[2][j]:
        ans = True

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

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

Submission status: Accepted

Solution code:
d=[[int(s) for s in input().split()] for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
for i in range(len(B)):
    for j in range(3):
        for k in range(3):
            if B[i]==d[j][k]:
                d[j][k]=-1
x=0
for i in range(3):
    if d[i][0]==d[i][1]==d[i][2]==-1 or d[0][i]==d[1][i]==d[2][i]==-1:
        x+=1
        print("Yes")
        break
if x==0:
    if d[0][0]==d[1][1]==d[2][2]==-1 or d[0][2]==d[1][1]==d[2][0]==-1:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
l=[]
for i in range(3):
    l.append(list(map(int,input().split())))
d=list(zip(*l))
s=[]
f=0
n=int(input())
for i in range(n):
    s.append(int(input()))
for i in range(3):
    c=0
    for j in range(3):
        if(l[i][j] in s):
            c+=1
    if(c==3):
        f=1
        break
if(l[1][1] in s and l[0][0] in s and l[2][2] in s):
    f=1
if(l[0][2] in s and l[1][1] in s and l[2][0] in s):
    f=1
for i in range(3):
    c=0
    for j in range(3):
        if(d[i][j] in s):
            c+=1
    if(c==3):
        f=1
        break
if(f==1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = [input().split() for _ in range(3)]
N = int(input())
c = [[False]*3 for _ in range(3)]
for _ in range(N):
    B = input()
    for i in range(3):
        if B in A[i]:
            c[i][A[i].index(B)] = True

def solve(c):
    y = "Yes"
    n = "No"
    for i in range(3):
        if c[i][0] and c[i][1] and c[i][2]:
            return y
        if c[0][i] and c[1][i] and c[2][i]:
            return y
    if c[0][0] and c[1][1] and c[2][2]:
        return y
    if c[0][2] and c[1][1] and c[2][0]:
        return y

    return n

print(solve(c))

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

d=[[0]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      d[i][j]=1
      
if d[0][0]==1 and d[0][1]==1 and d[0][2]==1:
  print('Yes')
elif d[1][0]==1 and d[1][1]==1 and d[1][2]==1:
  print('Yes')
elif d[2][0]==1 and d[2][1]==1 and d[2][2]==1:
  print('Yes')
elif d[0][0]==1 and d[1][1]==1 and d[2][2]==1:
  print('Yes')
elif d[0][0]==1 and d[1][0]==1 and d[2][0]==1:
  print('Yes')
elif d[0][1]==1 and d[1][1]==1 and d[2][1]==1:
  print('Yes')
elif d[0][2]==1 and d[1][2]==1 and d[2][2]==1:
  print('Yes')
elif d[0][2]==1 and d[1][1]==1 and d[2][0]==1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
bingoSheet = [0 for x in range(9)]

for i in range(3):
    bingoRow = input().split()
    for j in range(3):
        bingoSheet[i*3 + j] = int(bingoRow[j])

bingoCount = int(input())

responses = []

for i in range(bingoCount):
    responses.append(int(input()))

hasBingo = False

step = 1
initialIndex = 0

for i in range(3):
    firstIndex = i*3
    subList = [bingoSheet[index] for index in [firstIndex, firstIndex+1, firstIndex+2]]
    if (all(elem in responses for elem in subList)):
        hasBingo = True
        break

for i in range(3):
    firstIndex = i
    subList = [bingoSheet[index] for index in [firstIndex, firstIndex+3, firstIndex+6]]
    if (all(elem in responses for elem in subList)):
        hasBingo = True
        break

subList = [bingoSheet[index] for index in [0, 4, 8]]
if (all(elem in responses for elem in subList)):
    hasBingo = True

subList = [bingoSheet[index] for index in [2, 4, 6]]
if (all(elem in responses for elem in subList)):
    hasBingo = True

if hasBingo:
    print('Yes')
    quit()

print('No')
quit()

Submission status: Accepted

Solution code:
matrix = []
for i in range(3):
    line = []
    line = input().split(" ")
    matrix.append(line)

n = int(input())
chosen = 0

for i in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == b:
                chosen += 1
                matrix[i][j] = 0
bingo = False
for i in range(3):
    if(matrix[i][0] == 0 and matrix[i][1] == 0 and matrix[i][2] == 0):
        bingo = True
        break
    elif(matrix[0][i] == 0 and matrix[1][i] == 0 and matrix[2][i] == 0):
        bingo = True
        break

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

Submission status: Accepted

Solution code:
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

a = [r1, r2, r3]

n = int(input())

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


if a[0][0] in b and a[0][1] in b and a[0][2] in b:
	print('Yes')
	quit()
if a[1][0] in b and a[1][1] in b and a[1][2] in b:
	print('Yes')
	quit()
if a[2][0] in b and a[2][1] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][0] in b and a[1][0] in b and a[2][0] in b:
	print('Yes')
	quit()
if a[0][1] in b and a[1][1] in b and a[2][1] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][2] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
	print('Yes')
	quit()
print('No')

Submission status: Accepted

Solution code:
"""Boot-camp-for-Beginners_Easy007_B_Bingo_25-August-2020.py"""
import numpy as np
import sys

A = list(list(map(int, input().split())) for i in range(3))
N = int(input())
b = list(int(input()) for i in range(N))

MARK = []
for k in range(N):
    for i in range(3):
        for j in range(3):
            if(A[i][j] == b[k]):
                MARK.append([i-1, j-1])
# print(MARK)
count_row_m1, count_row_0, count_row_p1, count_column_m1, count_column_0, count_column_p1, count_backslash, count_slash = 0, 0, 0, 0, 0, 0, 0, 0
for k in range(len(MARK)):
    if MARK[k][0] == -1:
        count_column_m1 += 1
    elif MARK[k][0] == 0:
        count_column_0 += 1
    else:
        count_column_p1 += 1

    if MARK[k][1] == -1:
        count_row_m1 += 1
    elif MARK[k][1] == 0:
        count_row_0 += 1
    else:
        count_row_p1 += 1

    if MARK[k][0] == MARK[k][1]:
        count_backslash += 1
    if MARK[k][0] == -MARK[k][1]:
        count_slash += 1
bingo = count_row_m1 >= 3 or count_row_0 >= 3 or count_row_p1 >= 3 or count_column_m1 >= 3 or count_column_0 >= 3 or count_column_p1 >= 3 or count_backslash >= 3 or count_slash >= 3
"""
print("count_column_m1", count_column_m1)
print("count_column_0", count_column_0)
print("count_column_p1", count_column_p1)
print("count_row_m1", count_row_m1)
print("count_row_0", count_row_0)
print("count_row_p1", count_row_p1)
print("count_backslash", count_backslash)
print("count_slash", count_slash)
"""
if bingo == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
c = []
c.append(np.sum(a,axis = 0))
c.append(np.sum(a,axis = 1))
d = np.prod(c)
if d == 0:
    print("Yes")
elif (a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0) or (a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = [0] * 9
nums = dict()
for i in range(3):
  temp = list(map(int, input().split()))
  for j, var in enumerate(temp):
    nums[var] = i * 3 + j
N = int(input())

for _ in range(N):
  i = int(input())
  if i in nums:
    A[nums[i]] = 1

bingo = [
  A[0] + A[1] + A[2],
  A[3] + A[4] + A[5],
  A[6] + A[7] + A[8],
  A[0] + A[3] + A[6],
  A[1] + A[4] + A[7],
  A[2] + A[5] + A[8],
  A[0] + A[4] + A[8],
  A[2] + A[4] + A[6]]

if 3 in bingo:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

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

for i in range(N):
    B_temp = int(input())
    B_list.append(B_temp)

ans_list = [[0 for _ in range(3)] for i in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B_list[i] == A_list[j][k]:
                ans_list[j][k] = 1

for i in range(3):
    ans_r_flag = 0
    ans_c_flag = 0
    for j in range(3):
        ans_r_flag += ans_list[i][j]
        ans_c_flag += ans_list[j][i]
        if ans_r_flag == 3 or ans_c_flag == 3:
            print("Yes")
            exit()
            
if ans_list[0][0] == 1 and ans_list[1][1] == 1 and ans_list[2][2] == 1:
    print("Yes")
    exit()
if ans_list[0][2] == 1 and ans_list[1][1] == 1 and ans_list[2][0] == 1:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
def main():
    a_lst = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b_lst = [int(input()) for _ in range(n)]
    appear = [[False for _ in range(3)] for _ in range(3)]
    is_bingo = False

    for b in b_lst:
        for r in range(3):
            for c in range(3):
                if a_lst[r][c] == b:
                    appear[r][c] = True

    for r in range(3):
        if appear[r][0] == True and appear[r][1] == True and appear[r][2] == True:
            is_bingo = True

    for c in range(3):
        if appear[0][c] == True and appear[1][c] == True and appear[2][c] == True:
            is_bingo = True

    if appear[0][0] == True and appear[1][1] == True and appear[2][2] == True:
        is_bingo = True

    if appear[0][2] == True and appear[1][1] == True and appear[2][0] == True:
        is_bingo = True

    if is_bingo:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
B = [[0 for i in range(3)] for j in range(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:
        B[j][k] = 1
c = []
for i in range(3):
  c.append(B[i][0] & B[i][1] & B[i][2])
  c.append(B[0][i] & B[1][i] & B[2][i])
c.append(B[0][0] & B[1][1] & B[2][2])
c.append(B[0][2] & B[1][1] & B[2][0])
if sum(c) > 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
x = []

for i in range(3):
  a =input().split()
  x.append(a)

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

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

for i in range(3):
    for j in range(3):
      if x[i][0] == x[i][1] == x[i][2]:
           print('Yes')
           exit()
      elif x[0][i] == x[1][i] == x[2][i]:
           print('Yes')
           exit()
      elif x[0][0] == x[1][1] == x[2][2]:
           print('Yes')
           exit()
      elif x[0][2] == x[1][1] == x[2][0]:
           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)]
mark = [[False, False, False] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:mark[i][j] = True

ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break      
for j in range(3):
    if mark[0][j] and mark[1][j] and mark[2][j]:
        ans = 'Yes'
        break
if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

Submission status: Accepted

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

Bingo = [[0, 0, 0] for _ in range(3)] 
for i in range(3):
  for j in range(3):
    for l in range(N):
      if(A[i][j] == b[l]):
        Bingo[i][j] = 1
bingo = 0
for i in range(3):
  if(Bingo[i][0]+Bingo[i][1]+Bingo[i][2])==3:
    bingo += 1
  elif(Bingo[0][i]+Bingo[1][i]+Bingo[2][i])==3:
    bingo += 1
if(Bingo[0][0]+Bingo[1][1]+Bingo[2][2])==3:
  bingo += 1
elif(Bingo[0][2]+Bingo[1][1]+Bingo[2][0])==3:
  bingo += 1

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

Submission status: Accepted

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

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

B=get_unique_list(B)
s=0
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    s+=1
elif A[0][2] in B and A[1][1] in B and A[2][0] in B:
    s+=1
else:    
    for i in range(3):
        if A[0][i] in B and A[1][i] in B and A[2][i] in B:
            s+=1
        elif A[i][0] in B and A[i][1] in B and A[i][2] in B:
            s+=1

if s>=1:
    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()))

card = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

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

yes = "Yes"
no = 'No'

answer = no

for i in range(3):
    if card[0][i] and card[1][i] and card[2][i]:
        answer = yes
for i in range(3):
    if card[i][0] and card[i][1] and card[i][2]:
        answer = yes
if card[0][0] and card[1][1] and card[2][2]:
    answer = yes
if card[0][2] and card[1][1] and card[2][0]:
    answer = yes

print(answer)

Submission status: Accepted

Solution code:
a=[]
for i in range(3):
    x,y,z=map(int,input().split())
    a.append(x)
    a.append(y)
    a.append(z)
b=int(input())
for i in range(b):
    c=int(input())
    if a.count(c)==1:
        a[a.index(c)]=0
if a[0]==a[1]==a[2] or a[3]==a[4]==a[5] or a[6]==a[7]==a[8]:
    print("Yes")
elif a[0]==a[3]==a[6] or a[1]==a[4]==a[7] or a[2]==a[5]==a[8]:
    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:
H = [[0] * 3 for i in range(3)]
A = [[0] * 3 for i in range(3)]

A[0][0],A[0][1],A[0][2] = map(int,input().split())
A[1][0],A[1][1],A[1][2] = map(int,input().split())
A[2][0],A[2][1],A[2][2] = map(int,input().split())

N = int(input())
for i in range(N):
	ball = int(input())
	for l in range(3):
		for c in range(3):
			if A[l][c] == ball:
				H[l][c] = 1
#print(H)
flag = 0
for l in range(3):
	if H[l][0] ==1 and H[l][1] ==1  and H[l][2] ==1:
		flag =1

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

if H[0][0]==1 and H[1][1]==1 and H[2][2]== 1:
	flag = 1

if H[2][0]==1 and H[1][1]==1 and H[0][2]== 1:
	flag = 1

if flag == 1:
	print("Yes")
else:
	print("No")
#A[2][1] = 10
#print(A)
#print(flag)

Submission status: Accepted

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

A=np.array(A)
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:
                continue
            B[j][k]=0

if 0 in np.sum(B,axis=0) or 0 in np.sum(B,axis=1) or B[0][0]+B[1][1]+B[2][2] == 0 or B[0][2]+B[1][1]+B[2][0] == 0:
    print("Yes")
else:
    print("No")