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(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

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

Submission status: Accepted

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
a = [[int(j) for j in input().split()] for i in range(3)]
# print("a =" ,a)
# print(a)
n = int(input())
ans = [[0 for j in range(3)] for i in range(3)]
b = [int(input()) for i in range(n)]
# print("b =", b)
# print("ans =", ans)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            # print("a[i][j] =", a[i][j], "i = ", i, "j = ", j)
            ans[i][j] = 1

# print("ans =", ans)
if ans[0][0] == ans[0][1] == ans[0][2] == 1:
    print("Yes")
elif ans[1][0] == ans[1][1] == ans[1][2] == 1:
    print("Yes")
elif ans[2][0] == ans[2][1] == ans[2][2] == 1:
    print("Yes")

elif ans[0][0] == ans[1][0] == ans[2][0] == 1:
    print("Yes")
elif ans[0][1] == ans[1][1] == ans[2][1] == 1:
    print("Yes")
elif ans[0][2] == ans[1][2] == ans[2][2] == 1:
    print("Yes")

elif ans[0][0] == ans[1][1] == ans[2][2] == 1:
    print("Yes")
elif ans[0][2] == ans[1][1] == ans[2][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())
b = list(map(int, [input() for i in range(n)]))

d = a

for k1, i in enumerate(a):
    for k2, j in enumerate(a[k1]):
        if a[k1][k2] in b:
            d[k1][k2]=0
l = 0
for i in range(3):
    if d[i][0] == 0 and d[i][1] == 0 and d[i][2] == 0:
        l += 1
    if d[0][i] == 0 and d[1][i]==0 and d[2][i]==0:
        l += 1
    if d[0][0] == 0 and d[1][1] == 0 and d[2][2] == 0:
        l += 1
    if d[0][2] == 0 and d[1][1] == 0 and d[2][0] == 0:
        l += 1
if l != 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

    
ans="No"

for i in range(3):
	if B.count(A[0][0])* B.count(A[0][1])* B.count(A[0][2])!=0\
or  B.count(A[1][0])* B.count(A[1][1])* B.count(A[1][2])!=0\
or  B.count(A[2][0])* B.count(A[2][1])* B.count(A[2][2])!=0\
or  B.count(A[0][0])* B.count(A[1][0])* B.count(A[2][0])!=0\
or  B.count(A[0][2])* B.count(A[1][2])* B.count(A[2][2])!=0\
or  B.count(A[0][1])* B.count(A[1][1])* B.count(A[2][1])!=0\
or  B.count(A[0][0])* B.count(A[1][1])* B.count(A[2][2])!=0\
or  B.count(A[0][2])* B.count(A[1][1])* B.count(A[2][0])!=0:
		ans="Yes"
    
print(ans)

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)]
a = D.count(A[0])
b = D.count(A[1])
c = D.count(A[2])
d = D.count(B[0])
e = D.count(B[1])
f = D.count(B[2])
g = D.count(C[0])
h = D.count(C[1])
i = D.count(C[2])
Sum1 = (a + b + c +1) % 4
Sum2 = (d + e + f + 1) % 4
Sum3 = (g + h + i +1) % 4
Sum4 = (a + e + i +1) % 4
Sum5 = (c + e + g +1) % 4
Sum6 = (a + d + g +1) % 4
Sum7 = (b + e + h +1) % 4
Sum8 = (c + f + i +1) % 4
list = [Sum1,Sum2,Sum3,Sum4,Sum5,Sum6,Sum7,Sum8]
s = list.count(0)
if s >= 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
whith1 = list(map(int,input().split()))
whith2 = list(map(int,input().split()))
whith3 = list(map(int,input().split()))
b = whith1 + whith2 + whith3
n = int(input())
num = []
for i in range(n):
    x = int(input())
    if x in b :
        b = [0 if i == x else i for i in b]
if b[0] == b[1] == b[2] or b[3] == b[4] == b[5] == 0 or b[6] == b[7] == b[8] == 0:
    print('Yes')
elif b[0] == b[3] == b[6] or b[1] == b[4] == b[7] == 0 or b[2] == b[5] == b[8] == 0:
    print('Yes')
elif b[0] == b[4] == b[8] or b[2] == b[4] == b[6] == 0 or b[6] == b[7] == b[8] == 0:
    print('Yes')
else :
    print('No')

Submission status: Accepted

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

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

for i in range(0, N):
  data = int(input())
  if data in A:
    A[A.index(data)] = 0

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = []
for i in range(3):
    a.append([int(i) for i in input().split()])
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

"""
c = [a[0][0], a[0][1], a[0][2]]
d = [a[1][0], a[1][1], a[1][2]]
e = [a[2][0], a[2][1], a[2][2]]
f = [a[0][0], a[1][0], a[2][0]]
g = [a[0][1], a[1][1], a[2][1]]
h = [a[0][2], a[1][2], a[2][2]]
i = [a[0][0], a[1][1], a[2][2]]
j = [a[2][0], a[1][1], a[0][2]]
"""

tmp = []
tmp2 = 0
tmp3 = 0
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                tmp.append([j,k])
                tmp2 += j
                tmp3 += k

count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
count6 = 0
flag = "No"
for i in range(len(tmp)):
    if tmp[i][0] == 0:
        count1 += 1
    if tmp[i][0] == 1:
        count2 += 1
    if tmp[i][0] == 2:
        count3 += 1
    if tmp[i][1] == 0:
        count4 += 1
    if tmp[i][1] == 1:
        count5 += 1
    if tmp[i][1] == 2:
        count6 += 1
if count1 >= 3 or count2 >= 3 or count3 >= 3 or count4 >= 3 or count5 >= 3 or count6 >= 3:
    flag = "Yes"
else:
    tmp4 = 0
    tmp5 = 0
    for i in range(len(tmp)):
        if (tmp[i][0] == 0 and tmp[i][1] == 0) or (tmp[i][0] == 1 and tmp[i][1] == 1) or (tmp[i][0] == 2 and tmp[i][1] == 2):
            tmp4 += 1
        if (tmp[i][0] == 0 and tmp[i][1] == 2) or (tmp[i][0] == 1 and tmp[i][1] == 1) or (tmp[i][0] == 2 and tmp[i][1] == 0):
            tmp5 += 1
    if tmp4 >= 3 or tmp5 >= 3:
        flag = "Yes"
print(flag)

Submission status: Accepted

Solution code:
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
#import math

#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
#S=[list(map(int,input().split())) for i in range(N)]




sc=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
data=[[0 for i in range(3)] for x in range(3)]

for b in B:
    for i in range(3):
        for x in range(3):
            if sc[i][x]==b:
                data[i][x]=1

for nlst in ([[[i,x] for i in range(3)] for x in range(3)],\
[[[x,i] for i in range(3)] for x in range(3)],\
[[[i,i] for i in range(3)]],\
[[[i,2-i] for i in range(2,-1,-1)]]):

    for lst in nlst:
        count=0
        for i,x in lst:
            count+=data[i][x]

        if count==3:
            print("Yes")
            exit()
print("No")

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())
L=[]
for i in range(n):
    L.append(int(input()))
M=[[0,0,0],[0,0,0],[0,0,0]]
for i in L:
    for j in range(3):
        for k in range(3):
            if i==A[j][k]:
                M[j][k]=1

for i in range(3):
    if sum(M[i])==3:
        print("Yes")
        exit()

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

if M[0][0]+M[1][1]+M[2][2]==3 or M[0][2]+M[1][1]+M[2][0]==3:
    print("Yes")
    exit()
    
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()))

b=set(b)
ch=[]
for i in range(3):
    ch.append([0,0,0])

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            ch[i][j]+=1

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

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

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

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

print("No")

Submission status: Accepted

Solution code:
from bisect import bisect_right, bisect_left
from collections import Counter, deque
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import groupby, permutations, combinations, product
from sys import stdin, stderr


# 最大公約数（ユークリッドの互除法）
# Python3.5 で math.gcd()が追加され、
# AtCoder環境と最新環境でパッケージが分かれてしまったので、自分で書いておく
def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)


# 拡張ユークリッド互除法
# 正整数x, y について、a*x + b*y == gcd(x,y)なるa,bを返す。
# 特に、互いに素なるx, yについては a*x + b*y == 1 となる a, b。
def exgcd(x, y):
    if y == 0:
        return 1, 0
    a, b = exgcd(y, x % y)
    return b, a - (x // y) * b


# 最小公倍数
def lcm(x, y):
    m = gcd(x, y)
    return (x // m) * (y // m)


def main():
    a = []
    a.append([int(x) for x in input().split()])
    a.append([int(x) for x in input().split()])
    a.append([int(x) for x in input().split()])
    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] = -1
    tate = [0, 0, 0]
    yoko = [0, 0, 0]
    naname = [0, 0]
    for i in range(3):
        for j in range(3):
            tate[i] += a[i][j]
            yoko[j] += a[i][j]
        naname[0] += a[i][i]
        naname[1] += a[i][2 - i]
    # print(tate)
    # print(yoko)
    # print(naname)
    if -3 in tate or -3 in yoko or -3 in naname:
        return "Yes"
    return "No"


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
a=[list(map(int,input().split())) for i 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:
        a[j][k]=-1

ans='No'
for i in a:
  if list(i)==[-1,-1,-1]:
    ans='Yes'
for i in zip(*a):
  if list(i)==[-1,-1,-1]:
    ans='Yes'
if a[0][0]+a[1][1]+a[2][2]==-3:
  ans='Yes'
if a[0][2]+a[1][1]+a[2][0]==-3:
  ans='Yes'


print(ans)

Submission status: Accepted

Solution code:
b1 = [int(x) for x in input().split()]
b2 = [int(x) for x in input().split()]
b3 = [int(x) for x in input().split()]
n = int(input())
li = list()
for i in range(n):
    li.append(int(input()))

b1_0 = False
b1_1 = False
b1_2 = False
b2_0 = False
b2_1 = False
b2_2 = False
b3_0 = False
b3_1 = False
b3_2 = False

for name in li:
    for j ,name2 in enumerate(b1):
        if(name2 == name):
            if(j == 0):
                b1_0 = True
            elif(j == 1):
                b1_1 = True
            else:
                b1_2 = True
    for k,name3 in enumerate(b2):
        if(name == name3):
            if(k == 0):
                b2_0 = True
            elif(k == 1):
                b2_1 = True
            else:
                b2_2 = True
    for l,name4 in enumerate(b3):
        if(name == name4):
            if(l == 0):
                b3_0 = True
            elif(l == 1):
                b3_1 = True
            else:
                b3_2 = True
            
if (b1_0 and b1_1 and b1_2):
    print("Yes")
elif (b2_0 and b2_1 and b2_2):
    print("Yes")
elif (b3_0 and b3_1 and b3_2):
    print("Yes")
elif (b1_0 and b2_0 and b3_0):
    print("Yes")
elif (b1_1 and b2_1 and b3_1):
    print("Yes")
elif(b1_2 and b2_2 and b3_2):
    print("Yes")
elif (b1_0 and b2_1 and b3_2):
    print("Yes")
elif (b1_2 and b2_1 and b3_0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
def resolve_b():
    card = [list(map(int, input().split())) for i in range(3)]
    l = [[0,0,0],[0,0,0],[0,0,0]]
    n = int(input())

    for i in range(n):
        num = int(input())
        for j in range(3):
            for k in range(3):
                if card[j][k] == num:
                    l[j][k] = 1
    nl = np.array(l)

    if sum(l[0]) == 3 or sum(l[1]) == 3 or sum(l[2]) == 3 or sum(l[:][0]) == 3 or sum(nl[:,0]) ==3 or sum(nl[:,1]) ==3 or sum(nl[:,2])==3:
        print("Yes")
    elif (l[0][0] + l[1][1] + l[2][2]) == 3 or (l[0][2] + l[1][1] + l[2][0])==3:
        print("Yes")
    else:
        print("No")
        
resolve_b()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
A = np.zeros((3,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())
b = np.ndarray(N)
for i in range(N):
  b[i] = int(input())

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

for i in range(N):
  B[A==b[i]] = 1

B1 = np.sum(B, axis=0)
B2 = np.sum(B, axis=1)
B3 = B[0,0] + B[1,1] + B[2,2]
B4 = B[2,0] + B[1,1] + B[0,2]

if(sum(B1 == 3) + sum(B2 == 3) >=1):
  print('Yes')
elif(B3 == 3 or B4 == 3):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
B1 = list(map(int, input().split()))
B2 = list(map(int, input().split()))
B3 = list(map(int, input().split()))
B= B1+B2+B3
N = int(input())
for n in range(N):
  num = int(input())
  B = [0 if i == num else i for i in B]
  if (B[0]+B[1]+B[2])*(B[3]+B[4]+B[5])*(B[6]+B[7]+B[8])*(B[0]+B[3]+B[6])*(B[1]+B[4]+B[7])*(B[2]+B[5]+B[8])*(B[0]+B[4]+B[8])*(B[2]+B[4]+B[6]) == 0:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
line1 = input().split(" ")
line2 = input().split(" ")
line3 = input().split(" ")
N = int(input())


line1hit = [0,0,0]
line2hit = [0,0,0]
line3hit = [0,0,0]

for i in range(N):
    val = input()

    for index in range(len(line1)):
        if val == line1[index]:
            line1hit[index] =1

        if val == line2[index]:
            line2hit[index] =1

        if val == line3[index]:
            line3hit[index] =1

if line1hit[0] * line1hit[1] * line1hit[2] == 1:
    print('Yes')
elif  line2hit[0] * line2hit[1] * line2hit[2] ==1:
    print('Yes')
elif  line3hit[0] * line3hit[1] * line3hit[2] ==1:
    print('Yes')

elif line1hit[0] * line2hit[0] * line3hit[0] ==1:
    print('Yes')
elif  line1hit[1] * line2hit[1] * line3hit[1] ==1:
    print('Yes')
elif  line1hit[2] * line2hit[2] * line3hit[2] ==1:
    print('Yes')
elif  line1hit[0] * line2hit[1] * line3hit[2] ==1:
    print('Yes')
elif  line1hit[2] * line2hit[1] * line3hit[0] ==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = []
for _ in range(3):
    a += list(map(int, input().split()))
n = int(input())
b = {int(input()): None for _ in range(n)}

r = [(ai in b) for ai in a]

combs = [
    [0,1,2],
    [3,4,5],
    [6,7,8],
    [0,3,6],
    [1,4,7],
    [2,5,8],
    [0,4,8],
    [2,4,6],
]
if any([all([r[c] for c in comb]) for comb in combs]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
import numpy as np

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

for _ in range(n):
    num = int(input())
    if num in card:
        pos = tuple(nd[0] for nd in np.where(card == num))
        card[pos[0], pos[1]] = 0

f = 0

for i in range(3):
    if sum(card[i,:]) == 0 or sum(card[:,i]) == 0:
        f = 1
    if card[0,0]+card[1,1]+card[2,2] == 0 or card[2,0]+card[1,1]+card[2,0] == 0:
        f = 1

if f:
    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 k in range(N):
    b.append(int(input()))

checklist = [A1, A2, A3, [A1[0], A2[0], A3[0]], [A1[1], A2[1], A3[1]], [A1[2], A2[2], A3[2]],[A1[0], A2[1], A3[2]],[A1[2], A2[1], A3[0]]]
#print(checklist)

ans = "No"

for cl in checklist:
    if set(cl).issubset(b) == True:
        ans = "Yes"
        break

print(ans)

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 mark[i][0] and mark[i][1] and mark[i][2]:
        ans = 'Yes'
        break

if ans != 'Yes':
    for j in range(3):
        if mark[0][j] and mark[1][j] and mark[2][j]:
            ans = 'Yes'
            break

if ans != 'Yes':
    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:
alist = [int(i) for i in input().split()]
blist = [int(i) for i in input().split()]
clist = [int(i) for i in input().split()]
n = int(input())
call_num = []
for i in range(n):
  call_num.append(int(input()))
lists = [alist,blist,clist]
dummy_list = [[0 for i in range(3)] for j in range(3)]
for i in call_num:
  for l,jlist in enumerate(lists):
    for m,k in enumerate(jlist):
      if k == i:
        dummy_list[l][m]=1
flag = 0
for i in range(3):
  if sum(dummy_list[i]) == 3:
    flag = 1
  if dummy_list[0][i]+dummy_list[1][i]+dummy_list[2][i]==3:
    flag = 1
if dummy_list[0][0]+dummy_list[1][1]+dummy_list[2][2] == 3:
  flag=1
if dummy_list[2][0]+dummy_list[1][1]+dummy_list[0][2] == 3:
  flag = 1
if flag==1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:

import sys
import collections

ue = list(map(int, input().split()))
ma = list(map(int, input().split()))
sita = list(map(int, input().split()))

n = int(input())

bingo = []

for s in range(n):
  bing = int(input())
  a = 0
  for i, j, k in zip(ue, ma, sita):
    if a == 3:
      continue
    if i == bing:
      ue[a] = '〇'
    if j == bing:
      ma[a] = '〇'
    if k == bing:
      sita[a] = '〇'
    a += 1

for i, j, k in zip(ue, ma, sita):
  if i == '〇' and j == '〇' and k == '〇':
    print('Yes')
    sys.exit()

x = collections.Counter(ue)
y = collections.Counter(ma)
z = collections.Counter(sita)

if x['〇'] == 3:
  print('Yes')
  sys.exit()
elif y['〇'] == 3:
  print('Yes')
  sys.exit()
elif z['〇'] == 3:
  print('Yes')
  sys.exit()

if ue[0] == '〇' and ma[1] == '〇' and sita[2] == '〇':
  print('Yes')
  sys.exit()
elif ue[2] == '〇' and ma[1] == '〇' and sita[0] == '〇':
  print('Yes')
  sys.exit()
print('No')

Submission status: Accepted

Solution code:
import sys
lines = sys.stdin.readlines()
line1 = lines.pop(0).split(' ')
line2 = lines.pop(0).split(' ')
line3 = lines.pop(0).split(' ')
N = int(lines.pop(0))

for i in range(N):
  for j in range(3):
    if int(lines[i]) == int(line1[j]):
      line1[j] = -1
    elif int(lines[i]) == int(line2[j]):
      line2[j] = -1
    elif int(lines[i]) == int(line3[j]):
      line3[j] = -1

if (line1[0] == line1[1] == line1[2]) or (line2[0] == line2[1] == line2[2]) or (line3[0] == line3[1] == line3[2]) or (line1[0] == line2[0] == line3[0]) or (line1[1] == line2[1] == line3[1]) or (line1[2] == line2[2] == line3[2]) or (line1[0] == line2[1] == line3[2]) or (line1[2] == line2[1] == line3[0]):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

lis_bingo = (
    [X[0], X[1], X[2], 
    [X[0][0], X[1][0], X[2][0]], 
    [X[0][1], X[1][1], X[2][1]], 
    [X[0][2], X[1][2], X[2][2]], 
    [X[0][0], X[1][1], X[2][2]], 
    [X[0][2], X[1][1], X[2][0]]]
)

n = 0
while n <= 7:
    ans_bool = set(lis_bingo[n]) <= set(b)
    if ans_bool:
        break
    n += 1

if ans_bool:
    print('Yes')
else :
    print("No")

Submission status: Accepted

Solution code:
A = []
A += list(map(int, input().split(' ')))
A += list(map(int, input().split(' ')))
A += list(map(int, input().split(' ')))

N = int(input())

B = []
for _ in range(N):
    b = int(input())
    try:
        idx = A.index(b)
        B.append(idx)
    except ValueError:
        pass

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

is_bingo = 'No'
for indices in bingo_indices:
    if (indices[0] in B) and (indices[1] in B) and (indices[2] in B):
        is_bingo = 'Yes'
        break

print(is_bingo)

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())
  if(a1[0]==b):
    a1[0]=0
  if(a1[1]==b):
    a1[1]=0
  if(a1[2]==b):
    a1[2]=0
  if(a2[0]==b):
    a2[0]=0
  if(a2[1]==b):
    a2[1]=0
  if(a2[2]==b):
    a2[2]=0
  if(a3[0]==b):
    a3[0]=0
  if(a3[1]==b):
    a3[1]=0
  if(a3[2]==b):
    a3[2]=0                                   
l1=[a1[0],a2[0],a3[0]]
l2=[a1[1],a2[1],a3[1]]
l3=[a1[2],a2[2],a3[2]]
l4=[a1[0],a1[1],a1[2]]
l5=[a2[0],a2[1],a2[2]]
l6=[a3[0],a3[1],a3[2]]
l7=[a1[0],a2[1],a3[2]]
l8=[a1[2],a2[1],a3[0]]
if(sum(l1)==0 or sum(l2)==0 or sum(l3)==0 or sum(l4)==0 or sum(l5)==0 or sum(l6)==0 or sum(l7)==0 or sum(l8)==0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def rtnIdx(bg, num):
    for i in range(len(bg)):
        for j in range(len(bg[0])):
            if bg[i][j] == num:
                return i, j
    return -1, -1


def checkBingo(bg, lis):
    isBingo = [[False for i in range(3)] for j in range(3)]
    for num in lis:
        i, j = rtnIdx(bg, num)
        if i != -1:
            isBingo[i][j] = True

    flag = False

    # check column/row
    for i in range(3):
        if isBingo[i][0] is True and isBingo[i][1] is True and isBingo[i][2] is True:
            flag = True
        if isBingo[0][i] is True and isBingo[1][i] is True and isBingo[2][i] is True:
            flag = True

    # check diagonals
    if isBingo[0][0] is True and isBingo[1][1] is True and isBingo[2][2] is True:
        flag = True

    if isBingo[0][2] is True and isBingo[1][1] is True and isBingo[2][0] is True:
        flag = True

    return flag


bingo = []

for _ in range(3):
    array = list(map(int, input().split()))
    bingo.append(array)

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

if checkBingo(bingo, lis):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
bingo = []
for _ in range(3):
    row = input().split()
    for i in row:
        bingo.append(int(i))
        
N = int(input())

for i in range(N):
    num = int(input())
    bingo = [0 if b == num else b for b in bingo]

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

Submission status: Accepted

Solution code:
import numpy as np


def resolve():
    a_list = list(map(int,input().split()))
    b_list = list(map(int,input().split()))
    c_list = list(map(int,input().split()))
    arr = np.array([a_list, b_list, c_list])

    n = int(input())
    for _ in range(n):
        num = int(input())
        arr = np.where(arr == num, 0, arr)

    if True in np.all(arr == 0, axis=0):
        print('Yes')
        return

    elif True in np.all(arr == 0, axis=1):
        print('Yes')
        return

    elif arr[0, 0] == 0 and arr[1, 1] == 0 and arr[2, 2] == 0:
        print('Yes')
        return

    elif arr[2, 0] == 0 and arr[1, 1] == 0 and arr[0, 2] == 0:
        print('Yes')
        return

    else:
        print('No')
        return
      
resolve()

Submission status: Accepted

Solution code:
x = [0] * 3
y = [0] * 3
z = [0] * 3
x[0], y[0], z[0] = map(int, input().split())
x[1], y[1], z[1] = map(int, input().split())
x[2], y[2], z[2] = map(int, input().split())
N=int(input())

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

for i in range(N):
    for j in range(3):
        if x[j]==b[i]:
            x[j]=0
        if y[j]==b[i]:
            y[j]=0
        if z[j]==b[i]:
            z[j]=0

ans=0

for i in range(3):
    if x[i]==0 and y[i]==0 and z[i]==0:
        ans=1
        break

if x[0]==0 and x[1]==0 and x[2]==0:
    ans=1
if y[0]==0 and y[1]==0 and y[2]==0:
    ans=1
if z[0]==0 and z[1]==0 and z[2]==0:
    ans=1
if x[0]==0 and y[1]==0 and z[2]==0:
    ans=1
if z[0]==0 and y[1]==0 and x[2]==0:
    ans=1

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

Submission status: Accepted

Solution code:
import sys

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

n = input()
n = int(n)

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
        
      if j == 2 and (a[0][k] == 0 and a[1][k] == 0 and a[2][k] == 0):
        print("Yes")
        sys.exit()
      
    if a[j][0] == 0 and a[j][1] == 0 and a[j][2] == 0:
      print("Yes")
      sys.exit()
    
  if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    print("Yes")
    sys.exit()
    
  if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    print("Yes")
    sys.exit()
  
print("No")

Submission status: Accepted

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

#print(A, N, b)

C = []

for i in range(3):
    _c = []
    for j in range(3):
        _c.append(A[i][j] in b)
    C.append(_c)

#print(C)

flag = False

for i in range(3):
    if all(C[i]):
        flag = True

for i in range(3):
    _c = []
    for j in range(3):
        _c.append(C[j][i])
    if all(_c):
        flag = True

if C[0][0] and C[1][1] and C[2][2]:
    flag = True

if C[0][2] and C[1][1] and C[2][0]:
    flag = True

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

Submission status: Accepted

Solution code:
b1=list(map(int,input().split()))
b2=list(map(int,input().split()))
b3=list(map(int,input().split()))
n=int(input())

for i in range(n):
    bb=int(input())
    for j in range(3):
        if bb==b1[j]:
            b1[j]=0
        elif bb==b2[j]:
            b2[j]=0
        elif bb==b3[j]:
            b3[j]=0
if sum(b1)==0 or sum(b2)==0 or sum(b3)==0:
    print("Yes")
elif b1[0]==b2[0]==b3[0]==0:
    print("Yes")
elif b1[1]==b2[1]==b3[1]==0:
    print("Yes")
elif b1[2]==b2[2]==b3[2]==0:
    print("Yes")
elif b1[0]==b2[1]==b3[2]==0:
    print("Yes")
elif b1[2]==b2[1]==b3[0]==0:
    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())

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
                break

#print(a)

ans = min(sum(a[0]), sum(a[1]), sum(a[2]),(a[0][0] + a[1][1] + a[2][2]), (a[0][2] + a[1][1] + a[2][0]),(a[0][0] + a[1][0] + a[2][0]),(a[0][1] + a[1][1] + a[2][1]),(a[0][2] + a[1][2] + a[2][2]))

print(["No","Yes"][ans == 0])

Submission status: Accepted

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
maru = []
for i in range(N):
  tmp = int(input())
  
  for y, row in enumerate(A):
    try:
      A[y][row.index(tmp)] = 0
      print([y, row.index(tmp)], "a")
      maru.append([y, row.index(tmp)])
      break
    except ValueError:
      pass

f = False
for i in range(3):
  if A[i][0] == 0 and A[i][0] == A[i][1] and A[i][1] == A[i][2]:
    f = True
for i in range(3):
  if A[0][i] == 0 and A[0][i] == A[1][i] and A[1][i] == A[2][i]:
    f = True
if A[0][0] == 0 and A[0][0] == A[1][1] and A[1][1] == A[2][2]:
  f = True
if A[0][2] == 0 and A[0][2] == A[1][1] and A[1][1] == A[2][0]:
  f = True
if f:
  print("Yes")
else:
  print("No")