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: Wrong Answer

Solution code:
bingo = [list(map(int,input().split())) for i in range(3)]
N = int(input())
for _ in range(N):
    n = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == n:
                bingo[i][j] = -1

for i in range(3):
    if sum(bingo[i]) == -3:
        print("Yes")
        break
else:
    for i in range(3):
        if bingo[0][i]+bingo[1][i]+bingo[2][i] == -3:
            print("Yes")
            break
    else:
        if bingo[0][0]+bingo[1][1]+bingo[2][2] == -3 or bingo[0][2]+bingo[1][1]+bingo[2][0]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
a,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = list(map(int, input().split()))
if (a and b and c) in A:
    print("Yes")
elif (d and e and f) in A:
    print("Yes")
elif (g and h and i) in A:
    print("Yes")
elif (a and d and g) in A:
    print("Yes")
elif (b and e and h) in A:
    print("Yes")
elif (c and f and i) in A:
    print("Yes")
elif (a and e and i) in A:
    print("Yes")
elif (c and e and g) in A:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
Aa = [0]*3
for i in range(3):
    Aa[i] = [int(j) for j in  input().split()]
N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())
A = [[False] * 3 for _ in range(3)]
for i in range(N):
    for k in range(3):
        for t in range(3):
            if Aa[k][t] == b[i]:
                A[k][t] = True
for i in range(3):
    if A[i] == [True,True,True]:
        print("Yes")
        exit()
for i in range(3):
    if A[i][0] == True and A[i][1] == True and A[2] == True:
        print("Yes")
        exit()
if A[0][0] == True and A[1][1] == True and A[2][2] == True:
    print("Yes")
    exit()
if A[0][2] == True and A[1][1] == True and A[2][0] == True:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input(_)) for _ in range(N)]
X = [[0 for _ in range(3)] for _ in range(3)]
for n in range(N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == B[n]:
                X[i][j] = 1
tate = any([all([X[i][j] for j in range(3)]) for i in range(3)])
yoko = any([all([X[i][j] for i in range(3)]) for j in range(3)])
nana = all([X[i][i] for i in range(3)]) or all([X[i][2 - i] for i in range(3)])
if tate or yoko or nana:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
for k in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                A[i][j] = True
for i in range(3):
    if A[i] == [True, True, True]:
        print("Yes")
        exit()
    elif A[i][0] == A[i][1] == A[i][2] == True:
        print("Yes")
        exit()
if A[0][0] == A[1][1] == A[2][2] == True:
    print("Yes")
    exit()
if A[0][2] == A[1][1] == A[2][0] == True:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
A = np.array([list(map(str, 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] = 'X'


if A[0][0] == A[1][1] == A[2][2] == 'X':
    print('Yes')
    exit()

if A[0][2] == A[1][1] == A[2][0] == 'X':
    print('Yes')
    exit()

if A[0][0] == A[0][1] == A[0][2] == 'X':
    print('Yes')
    exit()

if A[1][0] == A[1][1] == A[1][2] == 'X':
    print('Yes')
    exit()

if A[2][0] == A[2][1] == A[2][2] == 'X':
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    elif b in a2:
        a2[a2.index(b)] = 0
    elif b in a3:
        a3[a3.index(b)] = 0

if a1.count(0) == 3 or a3.count(0) == 3 or a3.count(0) == 3:
    print('Yes')
elif a1[0] == 0 and a2[0] == 0 and a3[0] == 0:
    print('Yes')
elif a1[1] == 0 and a2[1] == 0 and a3[1] == 0:
    print('Yes')
elif a1[2] == 0 and a2[2] == 0 and a3[2] == 0:
    print('Yes')
elif a1[0] == 0 and a2[1] == 0 and a3[2] == 0:
    print('Yes')
elif a1[2] == 0 and a2[1] == 0 and a3[0] == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
from math import factorial


def main(S):
    pass


if __name__ == '__main__':
    A = []
    B = [0] * 9
    for i in range(3):
        A += list(map(int, input().split()))
    n = int(input())

    for i in range(n):
        tmp = int(input())
        for j in range(9):
            if A[j] == tmp:
                B[j] = 1
    ans = 0
    for i in range(3):
        if (B[0 + i] == 1 and B[1 + i] == 1 and B[2 + i] == 1):
            ans = 1
    for i in range(3):
        if (B[0 + i] == 1 and B[3 + i] == 1 and B[6 + i] == 1):
            ans = 1
    if (B[0] == 1 and B[4] == 1 and B[8] == 1):
        ans = 1
    if (B[2] == 1 and B[4] == 1 and B[6] == 1):
        ans = 1

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

Submission status: Wrong Answer

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] = 0
if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
    print('yes')
elif A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0:
    print('yes')
elif A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0:
    print('yes')
elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
    print('yes')
elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
    print('yes')
elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
    print('yes')
elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('yes')
elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    print('yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    ans = A[0][0] in b and A[1][0] in b and A[2][0]
    ans = ans or A[0][1] in b and A[1][1] in b and A[2][1] in b
    ans = ans or A[0][2] in b and A[1][2] in b and A[2][2] in b

    ans = ans or A[0][0] in b and A[0][1] in b and A[0][2] in b
    ans = ans or A[1][0] in b and A[1][1] in b and A[1][2] in b
    ans = ans or A[2][0] in b and A[2][1] in b and A[2][2] in b

    ans = ans or A[0][0] in b and A[1][1] in b and A[2][2] in b
    ans = ans or A[2][0] in b and A[1][1] in b and A[0][2] in b

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

cnt = 0
for i in range(3):
    for j in range(3):
        if a[i][j] == True:
            cnt += 1
        if cnt == 3:
            print("Yes")
            exit()

cnt = 0
for i in range(3):
    for j in range(3):
        if a[j][i] == True:
            cnt += 1
        if cnt == 3:
            print("Yes")
            exit()

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

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

print("No")

Submission status: Wrong Answer

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

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

N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))


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

f = False
for b in B:
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                flag[row][col] = True
                f = True
if not f:
    print("No")
    exit(0)
    
# check (--)
for row in range(3):
    f = True
    for col in range(3):
        if not A[row][col]:
            f = False
            break
    if f:
        print("Yes")
        exit(0)

# check (|)
for row in range(3):
    f = True
    for col in range(3):
        if not A[col][row]:
            f = False
            break
    if f:
        print("Yes")
        exit(0)

# check (diag)
if flag[0][0] and flag[1][1] and flag[2][2]:
    print("Yes")
elif flag[0][2] and flag[1][1] and flag[2][0]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
f = [[False]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                f[i][j] = True
for i in range(3):
    if all(f[i]):
        break
    if f[0][i] and f[1][i] and f[2][0]:
        break
    if f[0][0] and f[1][1] and f[2][2]:
        break
    if f[0][2] and f[1][1] and f[2][0]:
        break
else:
    print('No')
    exit()
print("Yes")

Submission status: Wrong Answer

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

get_list1 = []
get_list2 = []
get_list3 = []
for n in range(N):
  _ = int(input())
  for idx,a1 in enumerate(A1):
    if a1 == _:
      get_list1.append(idx)

  for idx,a2 in enumerate(A2):
    if a2 == _:
      get_list2.append(idx)
      
  for idx,a3 in enumerate(A3):
    if a3 == _:
      get_list3.append(idx)
    

ans = 'No'
# OKなパターンを一つづつ
# 縦
if 0 in get_list1:
  if 0 in get_list2:
    if 0 in get_list3:
      ans = 'Yes'
if 1 in get_list1:
  if 1 in get_list2:
    if 1 in get_list3:
      ans = 'Yes'      
if 2 in get_list1:
  if 2 in get_list2:
    if 2 in get_list3:
      ans = 'Yes'      

# 横      
if len(get_list1) == 3:
  ans = 'Yes'
elif len(get_list2) == 3:
  ans = 'Yes'
elif len(get_list2) == 3:
  ans = 'Yes'
else:
  pass

# 斜め
if 0 in get_list1:
  if 1 in get_list2:
    if 2 in get_list3:
      ans = 'Yes'
if 2 in get_list1:
  if 1 in get_list2:
    if 0 in get_list3:
      ans = 'Yes'
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = "No"
for i in range(3):
    if sum(B[i]) == 3: ans = "Yes"

for j in range(3):
    if B[0][j] + B[1][j] + B[0][j] == 3:
        ans = "Yes"

if B[0][0] + B[1][1] + B[2][2] == 3:
    ans = "Yes"

if B[0][2] + B[1][1] + B[2][0] == 3:
    ans  = "Yes"

print(ans)

Submission status: Wrong Answer

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


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

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

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

for i in range(3):
    tate = flag[i][0]
    yoko = flag[0][i]
    for j in range(1,3):
        tate = tate and flag[i][j]
        yoko = yoko and flag[j][i]

na1 = flag[0][0] and flag[1][1] and flag[2][2]
na2 = flag[0][2] and flag[1][1] and flag[2][0]

if tate or yoko or na1 or na2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

n = int(input())

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

if(data[0][0] == True and data[1][1] == True and data[2][2]):
    print("Yes")
elif(data[1][0] == True and data[1][1] == True and data[1][2]):
    print("Yes")
elif(data[2][0] == True and data[2][1] == True and data[2][2]):
    print("Yes")
elif(data[0][0] == True and data[0][1] == True and data[0][2]):
    print("Yes")
elif(data[0][2] == True and data[1][1] == True and data[2][0]):
    print("Yes")
elif(data[0] == [True, True, True]):
    print("Yes")
elif(data[1] == [True, True, True]):
    print("Yes")
elif(data[2] == [True, True, True]):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
    bingo.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 bingo[j][k] == b:
                bingo[j][k] = None
for i in range(3):
    row = True
    column = True
    for j in range(3):
        if bingo[i][j] != None:
            column = False
        if bingo[j][i] != None:
            row = False
naname = False
if bingo[0][0] == bingo[1][1] == bingo[2][2] == None or bingo[0][2] == bingo[1][1] == bingo[2][0] == None:
    naname = True
if row or column or naname:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for b in B:
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                A[row][col] = 0

ans = 'No'
for row in range(3):
    if sum([A[row][col] for col in range(3)]) == 0:
        ans = 'Yes'
        break

for col in range(3):
    if sum([A[row][col] for row in range(3)]) == 0:
        ans = 'Yes'
        break

if sum([A[i][i] for i in range(3)]) == 0:
    ans = 'Yes'
if sum(A[2 - j][2 - j] for j in range(3)) == 0:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline

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

B = [[0] * 3] * 3
N = int(input())
for _ in range(N):
    x = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == x:
                B[i][j] = 1

found = False

for i in range(3):
    if sum(A[i]) == 3:
        found = True

for j in range(3):
    sm = 0
    for i in range(3):
        sm += B[i][j]
    if sm == 3:
        found = True

sm = 0
for i in range(3):
    sm += B[i][i]
if sm == 3:
    found = True

sm = 0
for i in range(3):
    sm += B[i][2 - i]
if sm == 3:
    found = True

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

Submission status: Wrong Answer

Solution code:
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
for i in range(N):
    for h in range(3):
        for w in range(3):
            if b[i] == A[h][w]:
                A[h][w] = 0
if [0,0,0] in A:
    print('Yes')
else:
    ans = 'No'
    for i in zip(*A):
        if i == (0,0,0):
            ans = 'Yes'
            break
    print(ans)

Submission status: Wrong Answer

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

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

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                bingo[j][k]=True
flag=False
for i in range(3):
    if all(bingo[i]):
        flag=True

for j in range(3):
    if all([bingo[0][i],bingo[1][i],bingo[2][i]]):
        flag=True

if all([bingo[0][0],bingo[1][1],bingo[2][2]]):
        flag=True

if all([bingo[0][2],bingo[1][1],bingo[2][0]]):
    flag=True

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

Submission status: Wrong Answer

Solution code:
import sys
A=[[0]*3 for i in range(3)]
for i in range(3):
  A[i]=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]=10**10
for i in range(3):
  if sum(A[i])==3*10**10:
    print("Yes")
    sys.exit()
a=0
for i in range(3):
  a=a+A[i][0]
if a==3*10**10:
  print("Yes")
  sys.exit()
if A[0][0]+A[1][1]+A[2][2]==3*10**10 or A[0][2]+A[1][1]+A[2][0]==3*10**10:
  print("Yes")
  sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    A = [[int(i) for i in input().split()] for _ in range(3)]
    O = [[False] * 3 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: O[i][j] = True

    for i in range(3):
        if False in O[i]: continue
        else:
            print("Yes")
            break
    else:
        for i in range(3):
            if O[0][1] == O[1][i] == O[2][i] == True:
                print("Yes")
                break
        else:
            if O[0][0] == O[1][1] == O[2][2] == True:
                print("Yes")
            elif O[0][2] == O[1][1] == O[2][0] == True: print("Yes")
            else: print("No")

    return 0

if __name__ =="__main__":
    solve()

Submission status: Wrong Answer

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 i==[-1,-1,-1]:
    ans='Yes'
for i in zip(*a):
  if i==[-1,-1,-1]:
    ans='Yes'
if a[0][0]+a[1][1]+a[2][2]==-3:
  ans='Yes'
if a[2][2]+a[1][1]+a[0][0]==-3:
  ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
A = [[] for _ in range(3)]
for i in range(3):
    A[i] = [int(x) for x in input().strip().split()]
N = int(input())
if N >= 8:
    print('Yes')
    exit()

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

for i in range(3):
    if sum(A[i]) == 0:
        print('Yes')
        exit()
    if A[0][i] + A[1][i] + A[2][i] == 0:
        print('Yes')
        exit()

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

print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                A[i][j] = True
for i in range(3):
    if A[i] == [True, True, True]:
        print("Yes")
        exit()
    elif A[i][0] == A[i][1] == A[i][2] == True:
        print("Yes")
        exit()
if A[0][0] == A[1][1] == A[2][2] == True:
    print("Yes")
    exit()
if A[0][2] == A[1][1] == A[2][0] == True:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a = [LI() for _ in range(3)]
n = I()
b = [I() for _ in range(n)]
if n < 3:
    print('No')
    quit()
for i in range(3):
    for j in range(3):
        if a[i][j] not in b:
            break
    else:
        print('Yes')
        quit()

for i in range(3):
    for j in range(3):
        if a[j][i] not in b:
            break
    else:
        print('Yes')
        quit()

for i in range(3):
    if a[i][i] not in b:
        break
else:
    print('Yes')
    quit()

for i in range(3)[::-1]:
    if a[i][i] not in b:
        break
else:
    print('Yes')
    quit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
arr=[]
for i in range(3):
    mm=limii()
    arr.append(mm)

n=ii()

b=lin(n)

for i in range(3):
    for j in range(3):
        if arr[i][j] in b:
            arr[i][j]=0
chk=False

for i in range(3):
    if arr[:][i]==[0,0,0]:
        chk=True
    elif arr[i][:]==[0,0,0]:
        chk=True
if arr[0][0] ==0 and arr[1][1]==0 and arr[2][2]==0:
    chk=True
if chk==True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
        x = int(input())
        for j in range(3):
                for k in range(3):
                        if a[j][k]==x: a[j][k] = 0
ans = dcnt1 = dcnt2 = 0
for i in range(3):
        vcnt = hcnt = 0
        for j in range(3):
                if a[i][j]==0: vcnt += 1
                if a[j][i]==0: hcnt += 1

        if a[i][i]==0: dcnt1 += 1
        if a[2-i][2-i]==0: dcnt2 += 1
        if vcnt==3 or hcnt==3: ans = 1
if dcnt1==3 or dcnt2==3: ans = 1

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    ans = A[0][0] in b and A[1][0] in b and A[2][0]
    ans = ans or A[0][1] in b and A[1][1] in b and A[2][1]
    ans = ans or A[0][2] in b and A[1][2] in b and A[2][2]

    ans = ans or A[0][0] in b and A[0][1] in b and A[0][2]
    ans = ans or A[1][0] in b and A[1][1] in b and A[1][2]
    ans = ans or A[2][0] in b and A[2][1] in b and A[2][2]

    ans = ans or A[0][0] in b and A[1][1] in b and A[2][2]
    ans = ans or A[2][0] in b and A[1][1] in b and A[0][2]

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

for i in range(3):
    for j in range(3):
        if A[i][j] != -1:
            break
    else:
        print("Yes")
        exit()

for j in range(3):
    for i in range(3):
        if A[j][i] != -1:
            break
    else:
        print("Yes")
        exit()

for i in range(3):
    if A[i][i] != -1:
        break
    else:
        print("Yes")
        exit()

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

print("No")

Submission status: Wrong Answer

Solution code:
A=[tuple(map(int, input().split())) for _ in range(3)]
N=int(input())
B=[int(input())for _ in range(N)]
C=[[False]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                C[i][j]=True
ans=False
for i in range(3):
    ans|=all(C[i][j] for j in range(3))
    ans|=all(C[j][i] for j in range(3))
ans|=all(C[j][j] for j in range(3))
print("YNeos"[not ans::2])

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
        x = int(input())
        for j in range(3):
                for k in range(3):
                        if a[j][k]==x: a[j][k] = 0
ans = dcnt1 = dcnt2 = 0
for i in range(3):
        vcnt = hcnt = 0
        for j in range(3):
                if a[i][j]==0: vcnt += 1
                if a[j][i]==0: hcnt += 1

        if a[i][i]==0: dcnt1 += 1
        if a[2-i][2-i]==0: dcnt2 += 1
        if vcnt==3 or hcnt==3: ans = 1
if dcnt1 or dcnt2: ans = 1

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

Submission status: Wrong Answer

Solution code:
def main():
    A = [[int(i) for i in input().split()] for j in range(3)]
    seen = [[False]*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:
                    seen[j][k] = True
    flag = False
    for i in range(3):
        if all(seen[i]):
            flag = True
    for i in range(3):
        if all([seen[i][0], seen[i][1], seen[i][2]]):
            flag = True
    if all([seen[0][0], seen[1][1], seen[2][2]]) or all([seen[0][2], seen[1][1], seen[2][0]]):
        flag = True
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    A = [list(map(int,input().split())) for _ in range(3)]
    N = int(input())
    b = [int(input()) for _ in range(N)]
    bng = [[False]*3 for _ in range(3)]
    ans = "No"
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i] == A[j][k]:
                    bng[j][k] = True
    if (bng[0] == [True]*3 or
        bng[1] == [True]*3 or
        bng[0] == [True]*3 or
        bng[0][0] == bng[1][0] == bng[2][0] == True or
        bng[0][1] == bng[1][1] == bng[2][1] == True or
        bng[0][2] == bng[1][2] == bng[2][2] == True or
        bng[0][0] == bng[1][1] == bng[2][2] == True or
        bng[0][2] == bng[1][1] == bng[2][0] == True):
        ans = "Yes"
    print(ans)


if __name__ == '__main__':
    main()