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:
X = []
Y = []
Z = []
for i in range(3):
    x, y, z = map(str, input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)
N = int(input())

b = map(str, [input() for i in range(N)])

for x in sorted(b):
    X = [s.replace(x, 'OK') for s in X]
    Y = [s.replace(x, 'OK') for s in Y]
    Z = [s.replace(x, 'OK') for s in Z]

if ('OK' in X[0] and 'OK' in X[1] and 'OK' in X[2]
    or 'OK' in Y[0] and 'OK' in Y[1] and 'OK' in Y[2]
    or 'OK' in Z[0] and 'OK' in Z[1] and 'OK' in Z[2]
    or 'OK' in X[0] and 'OK' in Y[0] and 'OK' in Z[0]
    or 'OK' in X[1] and 'OK' in Y[1] and 'OK' in Z[1]
    or 'OK' in X[2] and 'OK' in Y[2] and 'OK' in Z[2]
    or 'OK' in X[0] and 'OK' in Y[1] and 'OK' in Z[2]
    or 'OK' in X[2] and 'OK' in Y[1] and 'OK' in Z[0]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
P = [input().split() for i in range(3)]
N = int(input())
b = [input() for i in range(N)]

P_ = [['0'] * 3] * 3
for j in range(3):
    for i in range(3):
        if P[i][j] in b:
            P_[i][j] = 1
        else:
            P_[i][j] = 0
            
ans = 'No'

# 横
for i in range(3):
    if [P_[i][j] for j in range(3)] == [1,1,1]:
        ans = 'Yes'
        
# 縦
for i in range(3):
    if [P_[j][i] for j in range(3)] == [1,1,1]:
        ans = 'Yes'
        
if [P_[i][i] for i in range(3)] == [1,1,1]:
    ans = 'Yes'
    
print(ans)

Submission status: Wrong Answer

Solution code:
listA = []
import itertools
listB = [0] * 9
for i in range(3):
    listA.append(input().split())
listA = list(itertools.chain.from_iterable(listA))
N = int(input())
for i in range(N):
    B = input()
    if B in listA:
        listB[listA.index(B)] = 1
listB = [1,1,0,1,0,0,1,0,0]
for i in range(3):
    if listB[i*3] == 1 and listB[i*3+1] == 1 and listB[i*3+2] == 1:
        print("Yes")
        exit()
for i in range(3):
    if listB[i] == 1 and listB[i+3] == 1 and listB[i+6] == 1:
        print("Yes")
        exit()
if listB[0] == 1 and listB[4] == 1 and listB[8] == 1:
    print("Yes")
    exit()
if listB[2] == 1 and listB[4] == 1 and listB[6] == 1:
    print("Yes")
    exit()
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 _ in range(n)]

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

Submission status: Wrong Answer

Solution code:
def checkbingo(bingo,bs):
  for b in bingo:
    cnt = 0
    for n in bs:
      if n in b:
        cnt +=1
    print("{}".format(cnt))
    if cnt == 3:
      return True
  return False

list1 = input('').split(' ')
list2 = input('').split(' ')
list3 = input('').split(' ')
bingo = [list1,list2,list3]
for i in range(0,2):
  bingo.append([list1[i],list2[i],list3[i]])
bingo.append([list1[0],list1[1],list2[2]])
bingo.append([list1[2],list1[1],list2[0]])
max_n = int(input(''))
bs = []
result = False
for n in range(0,max_n):
  b = input('')
  bs.append(b)
if checkbingo(bingo,bs):
  result = True

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

Submission status: Wrong Answer

Solution code:
import sys
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans_flag = True
ans = [[False, False, False], [False, False, False], [False, False, False]]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            ans[i][j] = True
            
for i in range(3):
    if ans[0][i] and ans[1][i] and ans[2][i]:
        print('Yes')
        sys.exit()
    if ans[i][0] and ans[i][1] and ans[i][2]:
        print('Yes')
        sys.exit()
    if not ans[i][i]:
        ans_flag = False

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

Submission status: Wrong Answer

Solution code:

A = list()
for _ in range(3):
    a1, a2, a3 = list(map(int, input().split()))
    A.append(a1)
    A.append(a2)
    A.append(a3)

N = int(input())

for _ in range(N):
    b = int(input())
    for i in range(len(A)):
        if A[i] == b:
            A[i] = 0

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

Submission status: Wrong Answer

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


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

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

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
a =[list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
#print(b)
check = [[0, 0, 0] for _ in range(3)]
#print(check)


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

#print(check)

#print(sum(check[0]))

if sum(check[0]) == 3 or sum(check[1]) == 3 or sum(check[2]) == 3:
    print('Yes')
    exit()
elif check[0][0]+check[1][0]+check[2][0] == 3 or check[0][1]+check[1][1]+check[2][1]== 3 or check[0][2]+check[1][2]+check[2][2] == 3:
     print('Yes')
     exit()
elif check[0][0]+check[1][1]+check[2][2] == 3:
    print('Yes')
    exit()

print('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 = []
for i in range(N):
    b = int(input())
    B.append(b)

for i in B:
    for j in range(3):
        if i == A1[j]:
            A1[j] = 0
        elif i == A2[j]:
            A2[j] = 0
        elif i == A3[j]:
            A2[j] = 0
        
if A1 == [0,0,0] or A2 == [0,0,0] or A3 == [0,0,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")
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")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a=[]
b=[]
nums=[]
ans="No"

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

n=int(input())

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

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]=0
                num=10*(j+1)+k+1
                nums.append(num)

nums.sort()

for i in nums:
    if i==i+1==i+2:
        ans="Yes"
    if i==i+10==i+20:
        ans="Yes"
        
if 11 in nums and 22 in nums and 33 in nums:
    ans="Yes"

if 13 in nums and 22 in nums and 31 in nums:
    ans="Yes"
    
print(ans)

Submission status: Wrong Answer

Solution code:
card = []
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
a,b,c = map(int,input().split())
card.append(a)
card.append(b)
card.append(c)
N = int(input())
for i in range(N):
    b = int(input())
    try:
        card[card.index(b)] = -1
    except:
        continue
if card[0] == card[1] == card[2] or card[3] == card[4] == card[5] or card[6] == card[7] == card[8] or card[0] == card[3] == card[7] or card[1] == card[4] == card[7] or card[2] == card[5] == card[8] or card[0] == card[4] == card[8] or card[2] == card[4] == card[6]:
    print("Yes")
else:
    print('No')

Submission status: Wrong Answer

Solution code:
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))
#print(Alist)
#print(Blist)
#print(Clist)
N=int(input())
mylist=[]
flaglist=[0,0,0,0,0,0,0,0] #8個のフラッグリスト
for i in range(N):
    mylist.append(int(input()))
    #print(mylist)
    
for i in range(3):
    for j in range(N):
        if Alist[i]==mylist[j]:
            flaglist[0]+=1
            
for i in range(3):
    for j in range(N):
        if Blist[i]==mylist[j]:
            flaglist[1]+=1
            
            
for i in range(3):
    for j in range(N):
        if Clist[i]==mylist[j]:
            flaglist[2]+=1
#ここまで横の列

for i in range(N):
    if Alist[0]==mylist[i]:
        flaglist[3]+=1
    elif Blist[0]==mylist[i]:
        flaglist[3]+=1
    elif Clist[0]==mylist[i]:
        flaglist[3]+=1
        
for i in range(N):
    if Alist[1]==mylist[i]:
        flaglist[4]+=1
    elif Blist[1]==mylist[i]:
        flaglist[4]+=1
    elif Clist[1]==mylist[i]:
        flaglist[4]+=1

for i in range(N):
    if Alist[2]==mylist[i]:
        flaglist[5]+=1
    elif Blist[2]==mylist[i]:
        flaglist[5]+=1
    elif Clist[2]==mylist[i]:
        flaglist[5]+=1
        
for i in range(N):
    if Alist[2]==mylist[i]:
        flaglist[6]+=1
    elif Blist[1]==mylist[i]:
        flaglist[6]+=1
    elif Clist[0]==mylist[i]:
        flaglist[6]+=1
        
for i in range(N):
    if Alist[0]==mylist[i]:
        flaglist[7]+=1
    elif Blist[1]==mylist[i]:
        flaglist[7]+=1
    elif Clist[2]==mylist[i]:
        flaglist[7]+=1
        
if max(flaglist)>0:
    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
    cross = 0
    ucross = 0
    for j in range(3):
        if sum(a[j][:]) == 0 or sum([row[j] for row in a]) == 0:
            print("Yes")
            exit()
        cross += a[j][j]
        ucross += a[2-j][2-j]
    if cross == 0 or ucross == 0:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
a_list = []
for _ in range(3):
    a = list(map(int, input().split()))
    a_list = a_list + a
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a_list:
        a_list[a_list.index(b)] = 0
    else:
        continue
if a_list[:3] == 0 or a_list[3:6] == 0 or a_list[6:]==0:
    print("Yes")
elif a_list[0] == a_list[3] == a_list[6] == 0:
    print("Yes")
elif a_list[1] == a_list[4] == a_list[7] == 0:
    print("Yes")
elif a_list[2] == a_list[5] == a_list[8] == 0:
    print("Yes")
elif a_list[0] == a_list[4] == a_list[8] == 0:
    print("Yes")
elif a_list[2] == a_list[4] == a_list[6] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

flag = 0
for i in range(N):
  for j in range(3):
    if b[i] == A1[j]:
      A1[j] = 0
    elif b[i] == A2[j]:
      A2[j] = 0
    elif b[i] == A3[j]:
      A3[j] = 0
if A2[1] == 0:
  if A2[0] == 0 and A2[2] == 0:
    flag = 1
  elif A1[1] == 0 and A3[1] == 0:
    flag = 1
  elif A1[0] == 0 and A3[2] == 0:
    flag = 1
  elif A1[2] == 0 and A2[0] == 0:
    flag = 1
elif A1[0] == 0 and A1[1] == 0 and A1[2] == 0:
  flag = 1
elif A1[0] == 0 and A1[0] == 0 and A2[0] == 0:
  flag = 1
elif A1[2] == 0 and A2[2] == 0 and A3[2] == 0:
  flag = 1
elif A3[0] == 0 and A3[1] == 0 and A3[2] == 0:
  flag = 1
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans_flag = True
ans = [[False, False, False], [False, False, False], [False, False, False]]

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

print(ans)

for i in range(3):
    if ans[0][i] and ans[1][i] and ans[2][i]:
        print('Yes')
        sys.exit()
    if ans[i][0] and ans[i][1] and ans[i][2]:
        print('Yes')
        sys.exit()
    if not ans[i][i]:
        ans_flag = False

if ans_flag:
    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)]

ans=[set([a[0][0],a[0][1],a[0][2]]),set([a[1][0],a[1][1],a[1][2]]),set([a[2][0],a[2][1],a[2][2]]),set([a[0][0],a[1][0],a[2][0]]),set([a[0][1],a[1][1],a[2][1]]),set([a[0][2],a[1][2],a[2][2]]),set([a[0][0],a[1][1],a[2][2]]),set([a[0][2],a[1][2],a[2][0]])]
from itertools import combinations


for i in combinations(b, 3):
    if set(i) in ans:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A=[]
for i in range(0,3):
    k=list(map(int,input().split(' ')))
    A.append(k)
n=int(input())
b=[]
for i in range(0,n):
    b.append(int(input()))
for i in range(0,2):
    if (A[1][i] and A[2][i] and A[0][i]) in b:
        print('Yes')
        quit()
    if (A[i][1] and A[i][2] and A[i][0]) in b:
        print('Yes')
        quit()
if (A[0][0] and A[2][2] and A[1][1]) in b:
    print('Yes')
    quit()
if (A[0][2] and A[2][0] and A[1][1]) in b:
    print('Yes')
    quit()
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)]

s=[]
t=[]
cross_1=0
cross_2=0

ans="No"

for i in b:
    for j in range(3):
        if i in A[j]:
            s.append(j)
            t.append(A[j].index(i))
            if j==A[j].index(i):
                cross_1+=1
                if j==1:
                    cross_2+=1
            elif j==2-A[j].index(i):
                cross_2+=1
                print(cross_2)
for k in range(3):
    if s.count(k)==3:
        ans="Yes"
for l in range(3):
    if t.count(l)==3:
        ans=0
if cross_1==3:
    ans="Yes"
elif cross_2==3:
    ans="Yes"

print(ans)

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())
num =[]
for j in range(n):
    num.append(int(input()))
if a and b and c in num:
    print('Yes')
elif b and e and h in num:
    print('Yes')
elif c and f and i in num:
    print('Yes')
elif a and b and c in num:
    print('Yes')
elif d and e and f in num:
    print('Yes')
elif g and h and i in num:
    print('Yes')
elif a and e and i in num:
    print('Yes')
elif c and e and g in num:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

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

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

Submission status: Wrong Answer

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

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


for i in range(3):
    A.append([A[0][i] ,A[1][i] ,A[2][i]])
A.append([A[0][0] ,A[1][1] ,A[2][2]])

cnt1 = 0
for i in range(7):
    cnt = 0
    for j in range(3):
        for k in range(N):
            if A[i][j] == B[k]:
                cnt += 1
            if cnt == 3:
                cnt1 = 100
if cnt1 != 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

for i in B:
    if i in A1:
        A1[A1.index(i)] = "#"
    elif i in A2:
        A2[A2.index(i)] = "#"
    elif i in A3:
        A3[A3.index(i)] = "#"

flag = 0
for i in range(3):
    if A1[i] == "#":
        flag += 1
    elif A2[i] == "#":
        flag += 1
    elif A3[i] == "#":
        flag += 1
    if flag != 3:
        flag = 0
if flag == 3:
    print("Yes")
    exit()

if A1[0] == "#" and A1[1] == "#" and A1[2] == "#":
    print("Yes")
    exit()

if A2[0] == "#" and A2[1] == "#" and A2[2] == "#":
    print("Yes")
    exit()

if A3[0] == "#" and A3[1] == "#" and A3[2] == "#":
    print("Yes")
    exit()

if A1[0] == "#" and A2[1] == "#" and A3[2] == "#":
    print("Yes")
    exit()

if A3[0] == "#" and A2[1] == "#" and A1[2] == "#":
    print("Yes")
    exit()

print("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()))
#print(A1,A2,A3)
N = int(input())
for i in range(N):
  a = int(input())
  for j in range(3):
    for A11 in A1:
      if a == A11:
        A1[j] = 0
    for A22 in A2:
      if a == A22:
        A2[j] = 0
    for A33 in A3:
      if a == A33:
        A3[j] = 0
B1= [A1[0], A2[0], A3[0]]
B2= [A1[1], A2[1], A3[1]]
B3= [A1[2], A2[2], A3[2]]
C1= [A1[0], A2[1], A3[2]]
C2= [A1[2], A2[1], A3[0]]
#print(A1, A2, A3, B1, B2, B3, C1, C2)
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0 or sum(B1) == 0 or sum(B2) == 0 or sum(B3) == 0 or sum(C1) == 0 or sum(C2) == 0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys

def main():
    a=[]
    b=[]
    c=[]
    for i in range(3):
        tmp = input().replace('\n','').split(' ')
        tmp = list(map(int, tmp))
        a.append([tmp[0],False])
        a.append([tmp[1],False])
        a.append([tmp[2],False])
        c.append(tmp[0])
        c.append(tmp[1])
        c.append(tmp[2])
    n = int(input().replace('\n',''))
    for i in range(n):
        try:
            tmp = c.index(int(input().replace('\n','')))
            a[tmp][1] = True
        except ValueError:
            pass
    for i in range(3):
        if a[i][1] and a[i+3][1] and a[i+6][1]:
            res = 'Yes'
            break
        elif a[i*3][1] and a[i*3+1][1] and a[i*3+2][1]:
            res = 'Yes'
            break
        elif a[0][1] and a[4][1] and a[7][1] or a[2][1] and a[4][1] and a[6][1]:
            res = 'Yes'
            break
        else:
            res = 'No'
    print(res)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Submission status: Wrong Answer

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

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

    
ans="No"

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

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    A.append(input().split())
N = int(input())
for n in range(N):
    b = input()
    for a in range(3):
        for a2 in range(3):
            if A[a][a2]==b:
                A[a][a2] = "."
if A[0][0]=="." and A[0][1]=="." and A[0][2]==".":
    print("Yes")
elif A[1][0]=="." and A[1][1]=="." and A[1][2]==".":
    print("Yes")
elif A[2][0]=="." and A[2][1]=="." and A[2][2]==".":
    print("Yes")
elif A[0][0]=="." and A[1][0]=="." and A[2][0]==".":
    print("Yes")
elif A[0][1]=="." and A[1][1]=="." and A[2][1]==".":
    print("Yes")
elif A[0][2]=="." and A[1][2]=="." and A[1][2]==".":
    print("Yes")
elif A[0][0]=="." and A[1][1]=="." and A[2][2]==".":
    print("Yes")
elif A[0][2]=="." and A[1][1]=="." and A[2][0]==".":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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




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

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

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


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

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

Submission status: Wrong Answer

Solution code:
from numpy import *
A = [ list(map(int,input().split(" "))) for i in range(3)]
N=int(input())
b = [input() for i in range(N)]
C=zeros((3,3))
for i in range(0,3):
  for j in range(0,3):
    for k in range(0,N):
      if A[i][j]==b[k]:
        C[i][j]==1     #印つけ終わり
#for i in range(0,3):
 # if C[i]==[1,1,1]:
  #  print('Yes')
if C[0][0]==1 and C[1][1]==1 and C[2][2]==1:
  print("Yes") 
elif C[0][2]==1 and C[1][1]==1 and C[2][0]==1:  
   print("Yes") 
elif C[0][0]==1 and C[1][0]==1 and C[2][0]==1:
  print("Yes")    
elif C[0][1]==1 and C[1][1]==1 and C[2][1]==1:
  print("Yes")  
elif C[0][2]==1 and C[1][2]==1 and C[2][2]==1:
  print("Yes") 
elif C[0][0]==1 and C[0][1]==1 and C[0][2]==1:
  print("Yes")   
elif C[1][0]==1 and C[1][1]==1 and C[1][2]==1:
  print("Yes")   
elif C[2][0]==1 and C[2][1]==1 and C[2][2]==1:
  print("Yes") 
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def get(A, ar, ac):
    if ar > 2 or ar < -2 or ac > 2 or ar < -2:
        return 0
    return A[ar][ac]

def check(A, ar, ac):
    if 0 == get(A, ar-1, ac-1) and 0 == get(A, ar-2, ac-2) and 0 == get(A, ar+1, ac+1) and 0 == get(A, ar+2, ac+2):
        return True
    if 0 == get(A, ar+1, ac) and 0 == get(A, ar+2, ac) and 0 == get(A, ar-1, ac) and 0 == get(A, ar-2, ac):
        return True
    if 0 == get(A, ar, ac+1) and 0 == get(A, ar, ac+2) and 0 == get(A, ar, ac-1) and 0 == get(A, ar, ac-2):
        return True
    return False

A = [[0 for i in range(3)] for i in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for n in range(N):
    b = int(input())
    for ar in range(3):
        for ac in range(3):
            if A[ar][ac] == b:
                A[ar][ac] = 0
                if check(A, ar, ac):
                    print("Yes")
                    import sys
                    sys.exit(0)
print("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)]

B=[A1[0], A2[1], A3[2]]
C=[A1[2], A1[1], A3[0]]
if len(set(A1) & set(b))>2 or len(set(A2) & set(b))>2 or len(set(A3) & set(b))>2  or len(set(B) & set(b))>2 or len(set(C) & set(b))>2:
    print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import itertools
a = []
cnt_list = []
for _ in range(3):
    a += map(int, input().split())
n = int(input())
for _ in range(n):
    b = int(input())
    for i, j in enumerate(a):
        if b == j:
            cnt_list.append(i)
ans = 'No'
if len(cnt_list) > 2:
    cnt_list = set(cnt_list)
    for k in list(itertools.permutations(cnt_list, 3)):
        if sum(k) % 3 == 0:
            ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
x=[list(map(str,input().split())) for _ in range(3)]
N=int(input())
B=[input() for _ in range(N)]
flag=0
for i in range(3):
  for j in range(3):
    if x[i][j] in B:
      x[i][j]=True

for p in range(3):
  if x[p].count(True)==3:
    flag=1
lis=[]
lis2=[]
for a in range(3):
  for b in range(3):
    lis2.append(x[b][a])
  else:
    lis.append(lis2)
    lis2=[]

for q in range(3):
  if lis[q].count(True)==3:
    flag=1
if flag==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

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

arr = np.array([a1, a2, a3])
mask = np.zeros_like(arr)

for num in nums:
    idx = np.where(arr == num)

    if len(idx[0]) == 0:
        pass
    else:
        mask[idx] = 1

s_v = np.sum(mask, axis=0)
s_h = np.sum(mask, axis=0)
s_diag_1 = mask[0, 0] + mask[1, 1] + mask[2, 2]
s_diag_2 = mask[0, 2] + mask[1, 1] + mask[2, 0] 
s = np.maximum(np.concatenate([s_v, s_h, [s_diag_1], [s_diag_2]]) - 2, 0)

if np.max(s) > 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A1=[]
A2=[]
A3=[]
 # a11, a12, a13 = map(int,input().split())

a11, a12, a13 = map(int,input().split())
A1.append(a11)
A1.append(a12)
A1.append(a13)

a21, a22, a23 = map(int,input().split())
A2.append(a21)
A2.append(a22)
A2.append(a23)

a31, a32, a33 = map(int,input().split())
A3.append(a31)
A3.append(a32)
A3.append(a33)

N = int(input())
for i in range(N):
    b = int(input())
    if b==A1[0]:
        A1[0] ="OK"
    if b==A1[1]:
        A1[1]="OK"
    if b==A1[2]:
        A1[2]="OK"
    if b==A2[0]:
        A2[0] ="OK"
    if b==A2[1]:
        A2[1]="OK"
    if b==A2[2]:
        A2[2]="OK"
    if b==A3[0]:
        A3[0] ="OK"
    if b==A3[1]:
        A3[1]="OK"
    if b==A3[2]:
        A3[2]="OK"

ans =" No"
if A1[0]==A1[1] and A1[0]==A1[2]:
    ans ="Yes"
if A2[0]==A2[1] and A2[0]==A2[2]:
    ans ="Yes"
if A3[0]==A3[1] and A3[0]==A3[2]:
    ans ="Yes"

if A1[0]==A2[0] and A1[0]==A3[0]:
    ans ="Yes"
if A1[1]==A2[1] and A1[1]==A3[1]:
    ans ="Yes"
if A1[2]==A2[2] and A1[1]==A3[1]:
    ans ="Yes"

if A1[0]==A2[1] and A1[0]==A3[2]:
    ans ="Yes"
if A1[2]==A2[1] and A1[2]==A3[0]:
    ans ="Yes"

print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())
print(b)

if ((A[0][0] in b) & (A[0][1] in b) & (A[0][2] in b)):
    print('Yes')
elif ((A[1][0] in b) & (A[1][1] in b) & (A[1][2] in b)):
    print('Yes')
elif ((A[2][0] in b) & (A[2][1] in b) & (A[2][2] in b)):
    print('Yes')
elif ((A[0][0] in b) & (A[1][0] in b) & (A[2][0] in b)):
    print('Yes')
elif ((A[0][1] in b) & (A[1][1] in b) & (A[2][1] in b)):
    print('Yes')
elif ((A[0][2] in b) & (A[1][2] in b) & (A[2][2] in b)):
    print('Yes')
elif ((A[0][0] in b) & (A[1][1] in b) & (A[2][2] in b)):
    print('Yes')
elif ((A[0][2] in b) & (A[1][1] in b) & (A[2][0] in b)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

    for i in range(3):
        for j in range(3):
            for b in b_list:
                if(A[i][j] == b):
                    A[i][j] = 0

    flag = False
    for i in range(3):
        for j in range(3):
            if(i+1<3 and i+2<3 and j+1 < 3 and j+2 < 3):
                if(A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
        if(flag):
            break

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

if __name__ == "__main__":
    main()