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:
a=[[] for _ in range(3)]
for i in range(3):
  a[i]=list(map(int,input().split()))
l=[]
N=int(input())
for i in range(N):
  n=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==n:
        l.append([i,j])

def judge(l):
  if len(l)<=2:
    return 'No'
  else:
    if [0,0] in l and [1,1] in l and [2,2] in l:
      return 'Yes'
    else:
      dic1={}
      dic2={}
      for ij in l:
        i,j=ij[0],ij[1]
        if i not in dic1.keys():
          dic1[i]=1
        else:
          dic1[i]+=1
          if dic1[i]==3:
            return 'Yes'
        if j not in dic2.keys():
          dic2[j]=1
        else:
          dic2[j]+=1
          if dic2[j]==3:
            return 'Yes'
      return 'No'
print(judge(l))

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 number in b: #出た目を順番に確認
    for i in range(3):
        if number in a[i]: #numberがビンゴ表にあるかチェック
            a[i][a[i].index(number)] = 0 #i行のnumberに該当する要素を0に書き変え

if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes') #斜めのビンゴをチェック
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print("Yes") #行のビンゴをチェック
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes') #列のビンゴをチェック
            break
        else:
            print('No')

Submission status: Wrong Answer

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

for i in out: # 出た目を順番にiに入力
    for j in range(3):
        if i in bingo[j]: #iがbingoにあるかどうか
            bingo[j][bingo[j].index(i)] = 0

if bingo[0][0] == bingo[1][1] == bingo[2][2] == 0 or bingo[0][2] == bingo[1][1] == bingo[2][0] == 0:
    print("Yes")

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

Submission status: Wrong Answer

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

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

if sum(a[0][:]) == 0 or sum(a[1][:]) == 0 or sum(a[2][:]) == 0:
    print('Yes')
elif sum(a[:][0]) == 0 or sum(a[:][1]) == 0 or sum(a[:][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: Wrong Answer

Solution code:
A=[[int(i) for i in 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
flag=False
for h in range(3):
    cnt=0
    for w in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for w in range(3):
    cnt=0
    for h in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
cnt=0
for d in range(3):
    if A[d][d]==-1:
        cnt+=1
if cnt==3:
    flag=True
cnt=0
for d in range(3):
    if A[d][-d]==-1:
        cnt+=1
if cnt==3:
    flag=True
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
A=[[int(i) for i in 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
flag=False
for h in range(3):
    cnt=0
    for w in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for w in range(3):
    cnt=0
    for h in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for sign in range(2):
    cnt=0
    for d in range(3):
        if A[d][d*(1 if sign==0 else -1)]==-1:
            cnt+=1
    if cnt==3:
        flag=True
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
A=[[int(i) for i in 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
flag=False
for h in range(3):
    cnt=0
    for w in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for w in range(3):
    cnt=0
    for h in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for sign in range(2):
    cnt=0
    for d in range(3):
        if A[d][d*(1 if sign else -1)]==-1:
            cnt+=1
    if cnt==3:
        flag=True
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import itertools
l1=list(map(int,input().split(" ")))
l2=list(map(int,input().split(" ")))
l3=list(map(int,input().split(" ")))
b_st=[list(sorted(l1))]
b_st.append(list(sorted(l2)))
b_st.append(list(sorted(l3)))

b_st.append(list(sorted([l1[0],l2[0],l3[0]])))
b_st.append(list(sorted([l1[1],l2[1],l3[1]])))
b_st.append(list(sorted([l1[2],l2[2],l3[2]])))
b_st.append(list(sorted([l1[0],l2[1],l3[2]])))
b_st.append(list(sorted([l1[2],l2[1],l3[0]])))
con=int(input())
#print(b_st)
f=0
list1=[int(input())for n in range(0,con)]
list1=list(sorted(list1))
l2=[[a,b,c] for a,b,c in list(list(itertools.combinations(list1,3)))]
#print(l2)
#print(b_st)
for sw in b_st:
    for lw2 in l2:
        #print(sw)
        #print(lw2)
        if sw==lw2:
            print("Yes")
            f=1
            break
if f==0:
    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 number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    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 number in b:
    if b in a:
        a[a.index(b)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    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 number in b:
    if b in a:
        a[a.index(b)] = 0
if a[0][0] == a[1][1] == a[2][2]:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2]:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i]:
            print('Yes')
            break
    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 number in b:
    for i in range(3):
        a[i] = [-1 if k == number else k for k in a[i]]
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2]:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i]:
            print('Yes')
            break
    else:
        if a[0][0] == a[1][1] == a[2][2]:
            print('Yes')
            break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
row1 = input().split()
row2 = input().split()
row3 = input().split()

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

rows = [row1, row2, row3]

for i in range(0, 3):
    rows += [[row1[i], row2[i], row3[i]]]

rows += [[row1[0], row2[1], row3[2]]]
rows += [[row1[2], row2[1], row3[0]]]

print(rows)

for row in rows:
    j = 0
    for num in nums:
        if num in row:
            j += 1
        if j == 3:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
row1 = input().split()
row2 = input().split()
row3 = input().split()

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

rows = [row1, row2, row3]

for i in range(0, 3):
    rows += [row1[i], row2[i], row3[i]]

rows += [[row1[0], row2[1], row3[2]]]
rows += [[row1[2], row2[1], row3[0]]]

for row in rows:
    j = 0
    for num in nums:
        if num in row:
            j += 1
        if j == 3:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
lst=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
#print(lst,b)

lst_empty=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(3):
    for j in range(3):
        for k in b:
            if lst[i][j]==k:
                lst_empty[i][j]="x"
ans="No"
for i in lst_empty:
    if i[0]==i[1]==i[2]=="x":
        ans="Yes"
for j in list(zip(*lst_empty)):
    if j[0]==j[1]==j[2]=="x":
        ans="yes"
if lst_empty[0][0]==lst_empty[1][1]==lst_empty[2][2]=="x" or lst_empty[0][2]==lst_empty[1][1]==lst_empty[2][0]=="x":
    ans="Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7


def bingo(c):
    for i in range(3):
        flag = [False] * 3
        for j in range(3):
            if c[i][j]:
                flag[j] = True
        if flag[0] and flag[1] and flag[2]:
            return True
    for i in range(3):
        flag = [False] * 3
        for j in range(3):
            if c[j][i]:
                flag[j] = True
        if flag[0] and flag[1] and flag[2]:
            return True
    flag = [False] * 3
    for i in range(3):
        if c[i][i]:
            flag[i] = True
    if flag[0] and flag[1] and flag[2]:
        return True
    flag = [False] * 3
    for i in range(3):
        if c[i][2-i]:
            flag[i] = True
    if flag[0] and flag[1] and flag[2]:
        return True
    return False


a = [LIST() for _ in range(3)]
c = [[0] * 3] * 3
n = int(input())
for _ in range(n):
    b = int(input())
    d = -1
    e = -1
    for i in range(3):
        if b in a[i]:
            d = i
            e = a[i].index(b)
    if d != -1:
        c[d][e] = 1
    if bingo(c):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
import itertools as it
dic={}
bing=[[1 for i in range(3)] for j in range(3)]
for i in range(3):
    f=list(map(int,input().split()))
    for each in f:
        dic.update({each:(i,f.index(each))})
n=int(input())
for i in range(n):
    m=int(input())
    if m in dic.keys():
      place=dic[m]
      bing[place[0]][place[1]]=0
flag=False
code="000102101112202122"
code=code+code[::-1]
code=code+"001122021120"

for i in range(8):
    code_sep=code[6*i:6*i+6]
    p=0
    for j in range(3):
        cords=code_sep[2*j:2*j+2]
        p+=bing[int(cords[0])][int(cords[1])]
    if p==0:
        flag=True
        break
    
print("yes")if flag else print("No")

Submission status: Wrong Answer

Solution code:
A=[]
b=[]
c=[[0,0,0],[0,0,0],[0,0,0]]
d=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    x,y,z=map(int,input().split())
    A.append([x,y,z])

N = int(input())

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

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

if [1,1,1] in c:
    print('Yes')
elif [1,1,1] in d:
    print('Yes')
elif (c[0][0]+c[1][1]+c[2][2] == 3) or (d[0][0]+d[1][1]+d[2][2] == 3):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A=[]
b=[]
c=[[0,0,0],[0,0,0],[0,0,0]]
d=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    x,y,z=map(int,input().split())
    A.append([x,y,z])

N = int(input())

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

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

print(c)
print(d)

if [1,1,1] in c:
    print('Yes')
elif [1,1,1] in d:
    print('Yes')
elif (c[0][0]+c[1][1]+c[2][2] == 3) or (d[0][0]+d[1][1]+d[2][2] == 3):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A=[]
b=[]
c=[[0,0,0],[0,0,0],[0,0,0]]
d=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    x,y,z=map(int,input().split())
    A.append([x,y,z])

N = int(input())

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

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

if [1,1,1] in c[0:2]:
    print('Yes')
elif [1,1,1] in d[0:2]:
    print('Yes')
elif (c[0][0]+c[1][1]+c[2][2] == 3) or (d[0][0]+d[1][1]+d[2][2] == 3):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A=[]
b=[]
c=[[0,0,0],[0,0,0],[0,0,0]]
d=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    x,y,z=map(int,input().split())
    A.append([x,y,z])

N = int(input())

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

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

print(c)
print(d)

if [1,1,1] in c[0:2]:
    print('Yes')
elif [1,1,1] in d[0:2]:
    print('Yes')
elif (c[0][0]+c[1][1]+c[2][2] == 3) or (d[0][0]+d[1][1]+d[2][2] == 3):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a = [list(map(int, input().rstrip('\n').split())) for _ in range(3)]
    n = int(input().rstrip('\n'))
    for _ in range(n):
        b = int(input().rstrip('\n'))
        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] == a[i][1] == a[i][2] == -1:
            print("Yes")
            exit()
        elif a[i][0] == a[i][1] == a[i][2] == -1:
            print("Yes")
            exit()
    if a[0][0] == a[1][1] == a[2][2] == -1:
        print("Yes")
        exit()
    elif a[0][2] == a[1][1] == a[2][0] == -1:
        print("Yes")
        exit()
    print("No")


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
A=[]
for i in range(3):
  a=list(map(int,input().split()))
  A+=a
n=int(input())
C=[0]*9
for i in range(n):
  b=int(input())
  for j in range(9):
    if b==A[j]:
         C[j]+=1
if min(C[0:3])>0:
  print('Yes')
elif min(C[3:6])>0:
  print('Yes')
elif min(C[6:9])>0:
  print('Yes')
elif min(C[0::3])>0:
  print('Yes')
elif min(C[1::3])>0:
  print('Yes')
elif min(C[2::3])>0:
  print('Yes')
elif min(C[::4])>0:
  print('Yes')
elif min(C[2],min(C[4:6]))>0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

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

if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[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: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[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: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def check_bng(t):
	c = 0
	for i in range(3):
		if t[i][0] + t[i][1] + t[i][2] == -3:
			c = 1
		if t[0][i] + t[1][i] + t[2][i] == -3:
			c = -1
	if t[0][0] + t[1][1] + t[2][2] == -3 or t[2][0] + t[1][1] + t[0][2] == -3:
		c = 1

	return c

def check(b,t):
	for i in range(3):
		if t[i].count(b) == 1:
			t[i][t[i].index(b)] = -1
	return t

if __name__ == '__main__':
	A1 = [int(a) for a in input().split()]
	A2 = [int(a) for a in input().split()]
	A3 = [int(a) for a in input().split()]
	N = int(input())

	t = [A1, A2, A3]

	nlst = []
	for i in range(N):
		check(int(input()),t)

	if check_bng(t) == 1:
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

Solution code:
def main():
    A = []
    for _ in range(3):
        a = map(int,input().split())
        A += a
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for i in range(N):
        for j in range(9):
            if A[j] == B[i]:
                A[j] = -1
    ans = False
    #縦方向
    for i in range(3):
        if A[i] == -1 and A[i + 3] == -1 and A[i + 6] == -1 :
            ans = True
    #横
    for i in range(3):
        if A[3 * i] == - 1 and A[3 * i + 1] == -1 and A[3 * i +2] == -1 :
            ans = True
    #斜め
    for i in range(2,4):
        if A[4] == -1 and A[4 - i] == -1 and A[4 + i] == -1 :
            ans = True
    if ans :
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    A = []
    for _ in range(3):
        a = map(int,input().split())
        A += a
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for i in range(N):
        for j in range(9):
            if A[j] == B[i]:
                A[j] = -1
    ans = False
    #縦方向
    for i in range(3):
        if A[i] == -1 and A[i + 3] == -1 and A[i + 6] == -1 :
            ans = True
    #横
    for i in range(3):
        if A[i] == - 1 and A[i + 1] == -1 and A[i +2] == -1 :
            ans = True
    #斜め
    for i in [2,4]:
        if A[4] == -1 and A[4 - i] == -1 and A[4 + i] == -1 :
            ans = True
    if ans :
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    A = []
    for _ in range(3):
        a = map(int,input().split())
        A += a
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for i in range(N):
        for j in range(9):
            if A[j] == B[i]:
                A[j] = -1
    ans = False
    #縦方向
    for i in range(3):
        if A[i] == -1 and A[i + 3] == -1 and A[i + 6] == -1 :
            ans = True
    #横
    for i in range(3):
        if A[i] == - 1 and A[i + 1] == -1 and A[i +2] == -1 :
            ans = True
    #斜め
    for i in range(2,4):
        if A[4] == -1 and A[4 - i] == -1 and A[4 + i] == -1 :
            ans = True
    if ans :
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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())
b = [int(input()) for i in range(N)]

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 0
        if A2[j] == i:
            A2[j] = 0
        if A3[j] == i:
            A3[j] = 0
flag = False
A = [A1,A2,A3]
for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    sum_ = 0
    for j in range(3):
        sum_ += A[j][i]
    if sum_ == 0:
        flag = True

if A1[0] + A2[1] + A3[2] == 0:
    flag = True
if A1[2] * A2[1] + A3[0] == 0:
    flag = True
print('Yes' if flag 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())
b = [int(input()) for i in range(N)]

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 0
        if A2[j] == i:
            A2[j] = 0
        if A3[j] == i:
            A3[j] = 0
flag = False
A = [A1,A2,A3]
for i in range(3):
    if sum(A[i]) == 0:
        flag = True
    sum_ = 0
    for j in range(3):
        sum_ += A[j][i]
    if sum_ == 0:
        flag = True

if A1[0] + A2[1] + A3[2] == 0:
    flag = True
if A1[2] * A2[1] + A3[1] == 0:
    flag = True
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import numpy as np
a = []
a.append(input().split())
a.append(input().split())
a.append(input().split())
a = np.array(a).astype(int)

N = int(input())
for i in range(N):
    a[a == int(input())] = -1
    
def check(a):
    if a.max(axis=0).max() == -1:
        return "Yes"
    if a.max(axis=1).max() == -1:
        return "Yes"
    if a[0,0] + a[1,1] + a[2,2] == -3:
        return "Yes"
    if a[2,0] + a[1,1] + a[0,2] == -3:
        return "Yes"
    return "No"
print(check(a))

Submission status: Wrong Answer

Solution code:
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j, a_j in enumerate(a_list):
    if a_j == b_i:
      a_list[j] = -1
    
if ((a_list[0]==-1 and a_list[1] == -1 and a_list[2] == -1) or
    (a_list[3]==-1 and a_list[4] == -1 and a_list[5] == -1) or
    (a_list[6]==-1 and a_list[7] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[4] == -1 and a_list[8] == -1) or
	(a_list[2]==-1 and a_list[4] == -1 and a_list[6] == -1)):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j, a_j in enumerate(a_list):
    if a_j == b_i:
      a_list[j] = -1
    
if ((a_list[0]==-1 and a_list[1] == -1 and a_list[2] == -1) or
    (a_list[3]==-1 and a_list[4] == -1 and a_list[5] == -1) or
    (a_list[6]==-1 and a_list[7] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1) or
    (a_list[0]==-1 and a_list[4] == -1 and a_list[8] == -1) or
	(a_list[2]==-1 and a_list[4] == -1 and a_list[6] == -1)):
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
a1_1, a1_2, a1_3 = map(int, input().split())
a2_1, a2_2, a2_3 = map(int, input().split())
a3_1, a3_2, a3_3 = map(int, input().split())
a_list=[a1_1, a1_2, a1_3, a2_1, a2_2, a2_3, a3_1, a3_2, a3_3]
n = int(input())
b=[]
for i in range(n):
  b_i = int(input())
  b.append(b_i)
  for j, a_j in enumerate(a_list):
    if a_j == b_i:
      a_list[j] = -1
    
if ((a_list[0]==-1 and a_list[3] == -1 and a_list[6] == -1) or
    (a_list[1]==-1 and a_list[4] == -1 and a_list[7] == -1) or
    (a_list[2]==-1 and a_list[5] == -1 and a_list[8] == -1) or
	(a_list[0]==-1 and a_list[4] == -1 and a_list[8] == -1) or
	(a_list[2]==-1 and a_list[4] == -1 and a_list[6] == -1)):
  print("YES")
else:
  print("NO")

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] = 0
flag = False
for i in range(2):
    if sum( [ A[i][j] for j in range(2)] ) == 0:
        flag = True
    if sum( [ A[j][i] for j in range(2)] ) == 0:
        flag = True
if sum( [A[i][i] for i in range(2)] ) == 0 or sum( [A[2-i][i] for i in range(2)] ) == 0:
    flag = True
print("Yes") if flag else print("No")

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(2):
        for j in range(2):
            if A[i][j] == b:
                A[i][j] = 0
flag = False
for i in range(2):
    if sum( [ A[i][j] for j in range(2)] ) == 0:
        flag = True
    if sum( [ A[j][i] for j in range(2)] ) == 0:
        flag = True
if sum( [A[i][i] for i in range(2)] ) == 0 or sum( [A[2-i][i] for i in range(2)] ) == 0:
    flag = True
print("Yes") if flag else print("No")

Submission status: Wrong Answer

Solution code:

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

X = []
X += [set(A[i]) for i in range(3)]
X += [set([A[j][i] for j in range(3)]) for i in range(3)]
X += [set([A[0][2], A[1][1], A[2][0]]), set([A[2][2], A[1][1], A[0][0]])]

for x in X:
    if x in B:
        print('Yes')
        break
else:
    print('No')

Submission status: Wrong Answer

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

n=int(input())

b=list(int(input()) for i in range(n))

c=[[0]*3 for i in range(3)]

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

answer="No"

for i in range(3):
    if (c[i][0] and c[i][1] and c[i][2]):
        answer="Yes"
    if (c[0][i] and c[1][i] and c[2][i]):
        answer="Yes"
if (c[0][0] and c[1][1] and c[2][2]):
    answer="Yes"
if (c[0][2] and c[1][1] and c[2][0]):
    answer="Yes"

print(answer)

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())
b = [int(input()) for i in range(N)]

a = a1 + a2 + a3

for i in range(8):
    for j in range(N):
        if a[i] == b[j]:
           a[i] = 0
        else:
            pass

if a[0] == a[1] == a[2] == 0:
    ans = 'Yes'
elif a[3] == a[4] == a[5] == 0:
    ans = 'Yes'
elif a[6] == a[7] == a[8] == 0:
    ans = 'Yes'
elif a[0] == a[3] == a[6] == 0:
    ans = 'Yes'
elif a[1] == a[4] == a[7] == 0:
    ans = 'Yes'
elif a[2] == a[5] == a[8] == 0:
    ans = 'Yes'
elif a[0] == a[4] == a[8] == 0:
    ans = 'Yes'
elif a[2] == a[4] == a[6] == 0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

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())
b = [int(input()) for i in range(N)]

a = a1 + a2 + a3

for i in range(8):
    for j in range(N-1):
        if a[i] == b[j]:
           a[i] = 0
        else:
            pass

if a[0] == a[1] == a[2] == 0:
    ans = 'Yes'
elif a[3] == a[4] == a[5] == 0:
    ans = 'Yes'
elif a[6] == a[7] == a[8] == 0:
    ans = 'Yes'
elif a[0] == a[3] == a[6] == 0:
    ans = 'Yes'
elif a[1] == a[4] == a[7] == 0:
    ans = 'Yes'
elif a[2] == a[5] == a[8] == 0:
    ans = 'Yes'
elif a[0] == a[4] == a[8] == 0:
    ans = 'Yes'
elif a[2] == a[4] == a[6] == 0:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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