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:
def solve():
    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:
            return "Yes"
    for j in range(3):
        if A[0][j] == -1 and A[1][j] == -1 and A[2][j] == -1:
            return "Yes"
    if A[0][0] == -1 and A[1][1] == -1 and A[2][2] == -1:
        return "Yes"
    if A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1:
        return "Yes"
    return "No"

print(solve())

Submission status: Accepted

Solution code:



def solve(A,N,b) -> str:
    ans = [[0,0,0]for _ in range(3)]
    for bn in b:
        for n,a in enumerate(A):
            if(bn in a):
                ans[n][a.index(bn)] = 1
    for a in ans:
        if(sum(a) == 3):
            return "Yes"
    for a in zip(*ans):
        if(sum(a) == 3):
            return "Yes"
    if(ans[1][1] == 1):
            if(ans[0][0]==1 and ans[2][2]==1 or ans[0][2] == 1 and ans[2][0] == 1):
                return "Yes"
    else:
        return "No"


def main():
    A = []
    for _ in range(3):
        A.append(list(map(int,input().split())))
    N = int(input())
    b = [int(input())for _ in range(N)]
    # solve()
    print(solve(A,N,b[:]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

for i in range(3):
    for j in range(3):
        card[i][j] = "o" if card[i][j] in bingo else card[i][j]

ans = "No"
if card[0][0] == card[0][1] == card[0][2] \
    or card[1][0] == card[1][1] == card[1][2] \
    or card[2][0] == card[2][1] == card[2][2] \
    or card[0][0] == card[1][0] == card[2][0] \
    or card[0][1] == card[1][1] == card[2][1] \
    or card[0][2] == card[1][2] == card[2][2] \
    or card[0][0] == card[1][1] == card[2][2] \
    or card[0][2] == card[1][1] == card[2][0]:
    ans = "Yes"

print(ans)

Submission status: Accepted

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

for i in range(3):
    a[i][0],a[i][1],a[i][2] = list(map(int,input().split()))
N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                x[j][k] += 1

for i in range(3):
    if x[1][i]==x[2][i]==x[0][i]==1 \
    or x[i][1]==x[i][2]==x[i][0]==1 \
    or x[1][1]==x[2][2]==x[0][0]==1 \
    or x[0][2]==x[1][1]==x[2][0]==1:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

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

for i in range(3):
    a[i][0],a[i][1],a[i][2] = 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 b == a[j][k]:
                x[j][k] += 1

for i in range(3):
    if x[1][i]==x[2][i]==x[0][i]==1 \
    or x[i][1]==x[i][2]==x[i][0]==1 \
    or x[1][1]==x[2][2]==x[0][0]==1 \
    or x[0][2]==x[1][1]==x[2][0]==1:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
A_1=[int(x) for x in input().rstrip().split()]
A_2=[int(x) for x in input().rstrip().split()]
A_3=[int(x) for x in input().rstrip().split()]

N=int(input())
for i in range(N):
  b=int(input())
  if b in A_1:
    A_1[A_1.index(b)]=0
  if b in A_2:
    A_2[A_2.index(b)]=0
  if b in A_3:
    A_3[A_3.index(b)]=0


if A_1[0]==A_1[1]==A_1[2]==0:
  print("Yes")
elif A_1[0]==A_2[1]==A_3[2]==0:
  print("Yes")
elif A_1[0]==A_2[0]==A_3[0]==0:
  print("Yes")
elif A_2[0]==A_2[1]==A_2[2]==0:
  print("Yes")
elif A_3[0]==A_3[1]==A_3[2]==0:
  print("Yes")
elif A_1[1]==A_2[1]==A_3[1]==0:
  print("Yes")
elif A_1[2]==A_2[2]==A_3[2]==0:
  print("Yes")
elif A_1[2]==A_2[1]==A_3[0]==0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

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

flag = False

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

for i in range(3):
    if all(checker[i]):
        flag = True
        print('Yes')
        exit()

for i in range(3):
    for j in range(3):
        if checker[j][i] == True:
            temp = True
        else:
            temp = False
            break
    if temp == True:
        print('Yes')
        exit()


if checker[0][0] == checker[1][1] == checker[2][2] == True:
    print('Yes')
    exit()

if checker[0][2] == checker[1][1] == checker[2][0] == True:
    print('Yes')
    exit()


print('No')

Submission status: Accepted

Solution code:
r1 = list(map(lambda x:int(x),input().split()))
r2 = list(map(lambda x:int(x),input().split()))
r3 = list(map(lambda x:int(x),input().split()))
n = int(input())
for i in range(n):
  called = int(input())
  for j in range(3):
    if called==r1[j]:
      r1[j] = 0      
    elif called==r2[j]:
      r2[j] = 0
    elif called==r3[j]:
      r3[j] = 0
if r1==[0,0,0] or r2==[0,0,0] or r3==[0,0,0]:
  print("Yes")
elif r1[0]==r2[0]==r3[0] or r1[1]==r2[1]==r3[1] or r1[2]==r2[2]==r3[2]:
  print("Yes")
elif r1[0]==r2[1]==r3[2] or r1[2]==r2[1]==r3[0]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n = int(input())
B = [int(input()) for _ in range(n)]



for i in B:
    if i in l1:
        l1[l1.index(i)] = 0
    if i in l2:
        l2[l2.index(i)] = 0
    if i in l3:
        l3[l3.index(i)] = 0

l4 = [l1[0], l2[0], l3[0]]
l5 = [l1[1], l2[1], l3[1]]
l6 = [l1[2], l2[2], l3[2]]
l7 = [l1[0], l2[1], l3[2]]
l8 = [l1[2], l2[1], l3[0]]

ans=[l1, l2, l3, l4, l5, l6, l7, l8]

c = 0
for i in range(8):
    if ans[i] == [0, 0, 0]:
        c += 1

if c >= 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
N = int(input())
B = [int(input()) for _ in range(N)]

A = [a11, a12, a13, a21, a22, a23, a31, a32, a33]


for k in range(N):
    for p in range(9):
        if B[k] == A[p]:
            A[p] = 0

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

Submission status: Accepted

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = list()
for i in range(N):
  b.append(int(input()))
A = A1 + A2 + A3

l = list()

for i in range(9):
  cnt = b.count(A[i])
  l.append(cnt)

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

Submission status: Accepted

Solution code:
A = [0]*3
for i in range(3):
    A[i] = list(map(int,input().split()))
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))
             
for k in range(3):
    for j in range(3):
        if A[k][j] in B:
             A[k][j] = 0
answer = 'No'
for i in range(3):
    if sum(A[i])==0:
        answer = 'Yes'
        break
    count = 0
    for j in range(3):
        count += A[j][i]
    if count == 0:
        answer = 'Yes'
if A[0][0]+A[1][1]+A[2][2]==0:
    answer = 'Yes'
if A[0][2]+A[1][1]+A[2][0]==0:
    answer = 'Yes'
print(answer)

Submission status: Accepted

Solution code:
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
bs = [int(input()) for _ in range(N)]

A = np.array([A1, A2, A3])
mask = np.zeros_like(A)
for b in bs:
    mask += (A==b).astype(int)

mask = mask>0
if np.any(np.all(mask, axis=0)):
    print('Yes')
elif np.any(np.all(mask, axis=1)):
    print('Yes')
elif np.all(np.diag(mask)):
    print('Yes')
elif np.all(np.diag(mask[::-1])):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
bs = [int(input()) for _ in range(N)]

A = np.array([A1, A2, A3])
mask = np.zeros_like(A)
for b in bs:
    mask += (A==b).astype(int)

mask = mask>0
if np.any(np.all(mask, axis=0)):
    print('Yes')
elif np.any(np.all(mask, axis=1)):
    print('Yes')
elif np.all(np.diag(mask)):
    print('Yes')
# elif np.all(np.diag(mask.T)):
elif mask[0][2]&mask[1][1]&mask[2][0]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = []

for i in range(3):
    A.append(input().split())

N = int(input())

for n in range(N):
    b = input()
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if b == col:
                A[i][j] = True

res = False
for i in range(3):
    if A[i][0] == True and A[i][1] == True and A[i][2] == True:
        res = True
    if A[0][i] == True and A[1][i] == True and A[2][i] == True:
        res = True
if A[0][0] == True and A[1][1] == True and A[2][2] == True:
    res = True
if A[2][0] == True and A[1][1] == True and A[0][2] == True:
    res = True

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

Submission status: Accepted

Solution code:
A = []

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

N = int(input())

side = [0,0,0]
vertical = [0,0,0]


for i in range(N):
    number = int(input())
    if number in A:
        xy = A.index(number)
        y = xy // 3
        x = xy % 3
        vertical[y] += 1
        side[x] += 1
        A[xy] = 0

if 3 in side:
    print('Yes')
    exit();
if 3 in vertical:
    print('Yes')
    exit();
if A[4]==0 and A[0]==0 and A[8]==0:
    print('Yes')
    exit();
elif A[4]==0 and A[2]==0 and A[6]==0:
    print('Yes')
    exit();
    
print('No')

Submission status: Accepted

Solution code:
A = [[0 for _ in range(3)] for _ in range(3)]
B = [[False for _ in range(3)] for _ in range(3)]
b = []

for i in range(3):
    A[i][0],A[i][1],A[i][2] = map(int,input().split())

N = int(input())

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

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

judge = False

count3=0
count4=0

for i in range(3):
    count1=0
    count2=0
    
    if B[i][i]==True:
        count3 += 1
        if count3==3:
            judge=True
            break
        
    if B[2-i][i]==True:
        count4 +=1
        if count4==3:
            judge=True
            break
    
    for j in range(3):
        if B[i][j]==True:
            count1 += 1
            if count1 == 3:
                judge = True
                break
            
        if B[j][i]==True:
            count2 += 1
            if count2 == 3:
                judge = True
                break
if judge==True:
    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):
        if b in A[j]:
            A[j][A[j].index(b)] = 0

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

Submission status: Accepted

Solution code:
field = [[int(i) for i in input().split()] for j in range(3)]
N = int(input())
b_list = [int(input()) for n in range(N)]
bingo = False

for dan, row in enumerate(field):
    for suji, masu in enumerate(row):
        for b in b_list:
            if b == masu:
                field[dan][suji] = 0

for dan in field:
    if dan == [0, 0, 0]:
        bingo = True

hantei_list = []
i = 0
for dan in field:
    hantei_list.append(dan[i])
    i += 1
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
i = 2
for dan in field:
    hantei_list.append(dan[i])
    i -= 1
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
for dan in field:
    hantei_list.append(dan[0])
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
for dan in field:
    hantei_list.append(dan[1])
if hantei_list == [0, 0, 0]:
    bingo = True

hantei_list = []
for dan in field:
    hantei_list.append(dan[2])
if hantei_list == [0, 0, 0]:
    bingo = True

if bingo == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
index_A1 = -1
index_A2 = -1
index_A3 = -1
result_A1 = [0, 0, 0]
result_A2 = [0, 0, 0]
result_A3 = [0, 0, 0]

for i in range(N):
    b = int(input())
    try:
        index_A1 = A1.index(b)
        if index_A1 > -1:
            result_A1[index_A1] = 1
    except ValueError:
        index_A1 = -1

    try:
        index_A2 = A2.index(b)
        if index_A2 > -1:
            result_A2[index_A2] = 1
    except ValueError:
        index_A2 = -1

    try:
        index_A3 = A3.index(b)
        if index_A3 > -1:
            result_A3[index_A3] = 1
    except ValueError:
        index_A3 = -1

if sum(result_A1) == 3 or sum(result_A2) == 3 or sum(result_A3) == 3:
    print('Yes')
    sys.exit()

for i in range(3):
    if result_A1[i] + result_A2[i] + result_A3[i] == 3:
        print('Yes')
        sys.exit()

if result_A1[0] + result_A2[1] + result_A3[2] == 3:
    print('Yes')
    sys.exit()

if result_A3[0] + result_A2[1] + result_A1[2] == 3:
    print('Yes')
    sys.exit()

print('No')

Submission status: Accepted

Solution code:
a11,a12,a13,a21,a22,a23,a31,a32,a33,n,*b=map(int, open(0).read().split())
b=set(b)
if {a11,a12,a13}<=b or {a21,a22,a23}<=b or {a31,a32,a33}<=b or {a11,a21,a31}<=b or {a12,a22,a32}<=b or {a13,a23,a33}<=b or {a11,a22,a33}<=b or{a13,a22,a31}<=b:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
n=int(input())
b=[]
for i in range(n):
  b.append(int(input()))

for i in range(0,n):
  for j in range(0,3):
    if b[i]==p[j]:
      p[j]=0
    if b[i]==q[j]:
      q[j]=0
    if b[i]==r[j]:
      r[j]=0

if (p[0]==p[1]==p[2] or
    q[0]==q[1]==q[2] or
    r[0]==r[1]==r[2] or
    p[0]==q[0]==r[0] or
    p[1]==q[1]==r[1] or
    p[2]==q[2]==r[2] or
    p[0]==q[1]==r[2] or
    p[2]==q[1]==r[0]):
  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)]
ans='No'
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=-1
for i in range(3):
    if sum(A[i])==-3:
        ans='Yes'
    if A[0][i]+A[1][i]+A[2][i]==-3:
        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:
bingo = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
number = [int(input()) for _ in range(N)]

check = [[0 for _ in range(3)] for _ in range(3)]

for i in range(N):
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == number[i]:
        check[j][k] = 1
        
ans = 'No'
for i in range(3):
  if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
    ans = 'Yes'
    
for i in range(3):
  if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
    ans = 'Yes'
    
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
  ans = 'Yes'
  
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
  ans = 'Yes'
  
print(ans)

Submission status: Accepted

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

N = int(input())

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

# check

marker = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

bingo_fl = False
for i in b:
    for n, An in enumerate(A):

        if i in An:
            m = An.index(i)

            marker[n][m] = 1

            break

if (
        [1, 1, 1] in [marker[i][:] for i in range(3)] or
        [1, 1, 1] in [[marker[0][i], marker[1][i], marker[2][i]] for i in range(3)] or
        [1, 1, 1] == [marker[0][0], marker[1][1], marker[2][2]] or
        [1, 1, 1] == [marker[0][2], marker[1][1], marker[2][0]]
):
    bingo_fl = True

if bingo_fl is True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = [0] *9

a[0], a[1], a[2] = list(map(int, input().split()))
a[3], a[4], a[5] = list(map(int, input().split()))
a[6], a[7], a[8] = list(map(int, input().split()))

n = int(input())

b = [0]*9

for i in range(n):
    c = int(input())
    for j in range(9):
        if a[j] == c:
            b[j] = 1

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

Submission status: Accepted

Solution code:
a_1 = list(map(int,input().split(" ")))
a_2 = list(map(int,input().split(" ")))
a_3 = list(map(int,input().split(" ")))
n = int(input())
open_number =[]
for i in range(3):
  open_number.append([0,0,0])
for i in range(n):
  number = int(input())
  for j in range(3):
    if number == a_1[j]:
      open_number[0][j] = 1
    if number == a_2[j]:
      open_number[1][j] = 1
    if number == a_3[j]:
      open_number[2][j] = 1
bingo = False
line_1 = 0
line_2 = 0
line_3 = 0
cross_1 = 0
cross_2 = 0
for i in range(3):
  if not 0 in open_number[i]:
    bingo = True
  if open_number[i][0] == 1:
    line_1 += 1
  if open_number[i][1] == 1:
    line_2 += 1
  if open_number[i][2] == 1:
    line_3 += 1
  if open_number[i][i] == 1:
    cross_1 += 1
  if open_number[2-i][i] == 1:
    cross_2 += 1
  if line_1 == 3:
    bingo = True
  if line_2 == 3:
    bingo = True
  if line_3 == 3:
    bingo = True
  if cross_1 == 3:
    bingo = True
  if cross_2 == 3:
    bingo = True
if bingo:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
tf=[[0]*3 for _ in  range(3)]
n=int(input())
b=[]
for i in range(n):
  s=int(input())
  b.append(s)
for i in  b:
  for j in range(3):
    for k in range(3):
      if i==a[j][k]:
        tf[j][k]=1
for i in range(3):
  if tf[i]==[1,1,1]:
    print('Yes')
    exit()
  if [row[i] for row in tf]==[1,1,1]:
    print('Yes')
    exit()
if [tf[i][i] for i in range(3)]==[1,1,1]:
  print('Yes')
elif [tf[i][2-i] for i in range(3)]==[1,1,1]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = []
for i in range(3):
    array = list(map(int,input().split()))
    s.append(array)
N = int(input())
t = [int(input()) for i in range(N)]
 
for i in range(N):
    for j in range(3):
        for l in range(3):
            if t[i] == s[j][l]:
                s[j][l] = 0
 
if sum(s[0]) == 0 or sum(s[1]) == 0 or sum(s[2]) == 0 or s[0][0]+s[1][0]+s[2][0] == 0 or s[0][1]+s[1][1]+s[2][1] == 0 or s[0][2]+s[1][2]+s[2][2] == 0 or s[0][0]+s[1][1]+s[2][2] == 0 or s[2][0]+s[1][1]+s[0][2] == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

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

n = int(input())
a2 = [[0 for _ in range(3)]for _ in range(3)]

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

for i in range(3):
	if sum(a2[i]) == 3:
		print('Yes')
		sys.exit()
tate = 0
for i in range(3):
	for j in range(3):
		if a2[j][i] == 1:
			tate += 1
	if tate == 3:
		print('Yes')
		sys.exit()
	tate = 0
naname = 0
for i in range(3):
	if a2[i][i] == 1:
		naname += 1
if naname == 3:
	print('Yes')
	sys.exit()
naname = 0
for i in range(3):
	if a2[i][-i-1] == 1:
		naname += 1
if naname == 3:
	print('Yes')
	sys.exit()
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)]

ans='No'

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=-1

for i in range(3):
    if sum(A[i])==-3:
        ans='Yes'
    if A[0][i]+A[1][i]+A[2][i]==-3:
        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:
l = []
for i in range(3):
  l.append(list(map(int,input().split())))
n = int(input())
b = []
for i in range(n):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if l[i][j] == b:
        l[i][j] = 0

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

Submission status: Accepted

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

bingo = False
for n in range(int(input())):
    num = int(input())
    if num in A:
        A[A.index(num)] = 0
    if A[0] == A[1] == A[2] == 0: bingo = True
    if A[3] == A[4] == A[5] == 0: bingo = True
    if A[6] == A[7] == A[8] == 0: bingo = True
    if A[0] == A[3] == A[6] == 0: bingo = True
    if A[1] == A[4] == A[7] == 0: bingo = True
    if A[2] == A[5] == A[8] == 0: bingo = True
    if A[0] == A[4] == A[8] == 0: bingo = True
    if A[2] == A[4] == A[6] == 0: bingo = True

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

Submission status: Accepted

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

cross_line = []
reverse_cross = []
for i in range(3):
    vertiual_line = []
    cross_line.append(Bingo_list[i][i])
    reverse_cross.append(Bingo_list[i][2-i])
    for j_line in Bingo_list[:3]:
        vertiual_line.append(j_line[i])
    Bingo_list.append(vertiual_line)

Bingo_list.append(cross_line)
Bingo_list.append(reverse_cross)

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

for i_line in Bingo_list:
    for i_num in i_line:
        if not i_num in SelectNum:
            break
    else:
        ans = 'Yes'
        break
else:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
input1  = input().split()
input2  = input().split()
input3  = input().split()
N = int(input())

A = [input1, input2, input3]


for i in range(N):
  n = input()
  A[0] = ['0' if j == n else j for j in A[0]]
  A[1] = ['0' if j == n else j for j in A[1]]
  A[2] = ['0' if j == n else j for j in A[2]]



ans = 'No'
if A[1][1] == A[2][2] == A[0][0] == "0":
  ans = "Yes"

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

Submission status: Accepted

Solution code:
def main():
    import sys
    import math
    import collections
    
    A=[list(map(int,input().split())) for _ in range(3)]
    N=int(input())
    C=[]
    D=[]
    for _ in range(N):
        b=int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j]==b:
                    C.append(i)
                    D.append(j)
                    A[i][j]=0
    c=collections.Counter(C)
    d=collections.Counter(D)
    if 3 in c.values():
        print("Yes")
    elif 3 in d.values():
        print("Yes")
    elif A[0][0]==A[1][1] and A[1][1]==A[2][2]:
        print("Yes")
    elif A[0][2]==A[1][1] and A[1][1]==A[2][0]:
        print("Yes")
    else:
        print("No")

    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def i():
    return int(input())
def i2():
    return map(int,input().split())
def s():
    return str(input())
def l():
    return list(input())
def intl():
    return list(int(k) for k in input().split())

a=[intl() for _ in range(3)]
n=i()
b=[int(input()) for _ in range(n)]
flag=0
falg=0
for i in range(3):
	for j in range(3):
		if a[i][j] in b:
			a[i][j]=0
for i in range(3):
	for j in range(3):
		if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
			flag+=1
		elif a[0][j]==0 and a[1][j]==0 and a[2][j]==0:
			flag+=1
		elif i==j and a[i][j]==0:
			falg+=1
			if falg==3:
				flag+=1
if a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
	flag+=1
if flag>=1:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
A_1 = input().split()
A_2 = input().split()
A_3 = input().split()
A_1 = [int(k) for k in A_1]
A_2 = [int(k) for k in A_2]
A_3 = [int(k) for k in A_3]
A = []
A.append(A_1)
A.append(A_2)
A.append(A_3)

N = int(input())

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

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

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

Submission status: Accepted

Solution code:
mat = []
for _ in range(3):
    mat.append(list(map(int, input().split())))
N = int(input())
nums = set()
for _ in range(N):
    nums.add(int(input()))
rows = [3] * 3
cols = [3] * 3
diags = [3] * 2
for i in range(3):
    for j in range(3):
        if mat[i][j] in nums:
            rows[i] -= 1
            cols[j] -= 1
            if i == j:
                diags[0] -= 1
            if i + j == 2:
                diags[1] -= 1
print(["No", "Yes"][0 in (rows + cols + diags)])

Submission status: Accepted

Solution code:
S = [list(map(int, input().split())) for _ in range(3)]
s = []
for i in range(3):
    for j in range(3):
        s.append(S[i][j])
n = int(input())
a = [int(input()) for i in range(n)]
if (s[0]in a and s[1] in a and s[2] in a)or(s[3]in a and s[4] in a and s[5] in a)or(s[6]in a and s[7] in a and s[8] in a)or(s[0]in a and s[3] in a and s[6] in a)or(s[4]in a and s[1] in a and s[7] in a)or(s[2]in a and s[5] in a and s[8] in a)or(s[0]in a and s[4] in a and s[8] in a)or(s[2]in a and s[4] in a and s[6] in a):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
lia = input().split()
lib = input().split()
lic = input().split()
n=int(input())
num_list=[input() for i in range(n)]

ans=0

for i in range(0,3):
  for l in range(0,n):
    if lia[i]==num_list[l]:
      lia[i]=0
for i in range(0,3):
  for l in range(0,n):
    if lib[i]==num_list[l]:
      lib[i]=0
for i in range(0,3):
  for l in range(0,n):
    if lic[i]==num_list[l]:
      lic[i]=0
    
if lia.count(0)==3:
  ans=1
if lib.count(0)==3:
  ans=1
if lic.count(0)==3:
  ans=1
for k in range(0,3):
  if lia[k]==lib[k]==lic[k]:
    ans=1
    
if lia[0]==lib[1]==lic[2] or lia[2]==lib[1]==lic[0]:
  ans=1
  
if ans==1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import math
line1 = list(map(int, input().split()))
line2 = list(map(int, input().split()))
line3 = list(map(int, input().split()))
lines = [line1, line2, line3]
N = int(input())
List = [int(input()) for i in range(4, N + 4)]

for num in List:
    for i in range(len(lines)):
        for j in range(len(lines)):
            if lines[i][j] == num:
                lines[i][j] = -1

if (lines[0][0] == -1 and lines[0][1] == lines[0][0] and lines[0][2] == lines[0][0]) or (lines[1][0] == -1 and lines[1][1] == lines[1][0] and lines[1][2] == lines[1][0]) or (lines[2][0] == -1 and lines[2][1] == lines[2][0] and lines[2][2] == lines[2][0]) or (lines[0][0] == -1 and lines[1][0] == lines[0][0] and lines[2][0] == lines[0][0]) or (lines[0][1] == -1 and lines[1][1] == lines[0][1] and lines[2][1] == lines[0][1]) or (lines[0][2] == -1 and lines[1][2] == lines[0][2] and lines[2][2] == lines[0][2]) or (lines[0][0] == -1 and lines[1][1] == lines[0][0] and lines[2][2] == lines[0][0]) or (lines[0][2] == -1 and lines[1][1] == lines[0][2] and lines[2][0] == lines[0][2]):
    print("Yes")
else: print("No")