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 = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    A[i][0],A[i][1],A[i][2] = map(int, input().split())
N = int(input())
L = list()
Al = [i for x in A for i in x]
have = []
for _ in range(N):
    a = int(input())
    if a in Al:
        have.append(a)
if len(have)>=4:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for el in number:
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == el:
                bingo[i][j] = 0
flag = 0
for i in range(3):
    for j in range(3):
        if bingo[i][j] != 0:
            break
        flag = 1
for i in range(3):
    for j in range(3):
        if bingo[j][i] != 0:
            break
        flag = 1
    
if bingo[0][0] == 0:
    if bingo[1][1] == 0:
        if bingo[2][2] == 0:
            flag = 1
            
if bingo[0][2] == 0:
    if bingo[1][1] == 0:
        if bingo[2][0] == 0:
            flag = 1
            
if flag == 1:
    print("Yes")
    
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a=[0,0,0]
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] = 0
        break
    if a[j][k] == 0:
      break
done = 0
for i in range(3):
  if a[i][0] == a[i][1] == a[i][2] == 0 or a[0][i] == a[1][i] == a[2][i] == 0 :
    done = 1
    print('Yes')
    break
if done == 0 and (a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0) :
  print('Yes')
  done = 1

if done == 0:
  print('No')

Submission status: Wrong Answer

Solution code:
def check(cor, cc):
    flg = True
    for i in range(cc):
        for j in range(cc-1):
            if not (cor[i][j] == 1 and  cor[i][j+1] == 1):
                flg = False
                break
        if flg:
            return True
    
    flg = True
    for i in range(cc):
        for j in range(cc-1):
            if not (cor[j][i] == 1 and  cor[j+1][i] == 1):
                flg = False
                break
        if flg:
            return True
    
    flg = True
    for i in range(cc-1):
        if not (cor[i][i] == 1 and cor[i+1][i+1] == 1):
            flg = False
            break
    if flg:
        return True

    flg = True
    for i in range(cc-1):
        if not (cor[i][cc-1-i] == 1 and cor[i+1][cc-2-i]):
            flg = False
            break
    
    return False
    
    

tmp = list(map(int, input().split(' ')))
cc = len(tmp)
box = [[]for _ in range(cc)]
cor = [[0 for _ in range(cc)] for _ in range(cc)]
box[0] = tmp

for i in range(cc-1):
    box[i+1] = list(map(int, input().split(' ')))

N = int(input())
for _ in range(N):
    num = int(input())
    for i in range(cc):
        for j in range(cc):
            if num == box[i][j]:
                cor[i][j] = 1

if check(cor, cc):
    print('Yes')
else:
    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) ]

import numpy as np
a = np.array(a)
# print(a)
# print(n)
# print(b)

# print(a[1,0])
# print(a[2,2])

# c = a[1,1]
# print(c)


for i in range(n):
    if b[i] in a:
        r = np.where(a==b[i])
        a[r[0][0],r[1][0]] = 0
    else:
        pass


# print(a)
# print(a[1,0])

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

Submission status: Wrong Answer

Solution code:
A1 = list(map(str, input().split()))
A2 = list(map(str, input().split()))
A3 = list(map(str, input().split()))
#print(A1,A2,A3)
N = int(input())
for i in range(N):
  a = input()
  for j in range(3):
    for A11 in A1:
      if a == A11:
        A1[j] = '*'
    for A22 in A2:
      if a == A22:
        A2[j] = '*'
    for A33 in A3:
      if a == A33:
        A3[j] = '*'
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 ''.join(A1) == '***' or ''.join(A2) == '***' or ''.join(A3) == '***' or ''.join(B1) == '***' or ''.join(B2) == '***' or ''.join(B3) == '***' or ''.join(C1) == '***' or ''.join(C2) == '***':
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
card = {
    0: {0: a11, 1: a12, 2: a13},
    1: {0: a21, 1: a22, 2: a23},
    2: {0: a31, 1: a32, 2: a33}
}
n = int(input())
marks = [[0,0,0], [0,0,0], [0,0,0]]
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if card[j][k] == b:
                marks[j][k] = 1
if sum(marks[0]) == 3:
    print("Yes")
elif sum(marks[1]) == 3:
    print("Yes")
elif sum(marks[2]) == 3:
    print("Yes")
elif sum([marks[0][0],marks[0][1],marks[0][2]]) == 3:
    print("Yes")
elif sum([marks[1][0],marks[1][1],marks[1][2]]) == 3:
    print("Yes")
elif sum([marks[2][0],marks[2][1],marks[2][2]]) == 3:
    print("Yes")
elif sum([marks[0][0],marks[1][1],marks[2][2]]) == 3:
    print("Yes")
elif sum([marks[2][0],marks[1][1],marks[0][2]]) == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

#print(L)
n = int(input())
li = []
for i in range(n):
    li.append(int(input()))
flag = False
for i in range(3):
    for j in range(3):
        if L[i][j] in li:
            flag = True
        if flag :
            print("Yes")
            exit()
for j in range(3):
    for i in range(3):
        if L[i][j] in li:
            flag = True
        if flag:
            print("Yes")
            exit()
print("NO")

Submission status: Wrong Answer

Solution code:
bingo = []
checklists = []
for i in range(3):
  lists = list(map(int,input().split()))
  bingo.append(lists)
num = int(input())
for i in range(num):
  checklists.append(int(input()))
for i in range(3):
  for j in range(3):
    if bingo[i][j] in checklists:
        bingo[i][j] = 0
result = "No"
for i in range(3):
  for k in range(3):
    yoko = 0
    tate = 0
    if bingo[i][k] == 0:
      yoko += 0
    elif bingo[k][i] == 0:
      tate += 0
  if (yoko or tate) == 3:
    result = "Yes"
naname1 = 0
naname2 = 0
for i in range(3):
  if bingo[i][i] == 0:
    naname1 += 1
  elif bingo[-i][-i] == 0:
    naname2 += 1
if (naname1 or naname2) == 3:
  result = "Yes"
print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np

mat = []

for i in range(3):
	(a,b,c)= input().split(' ')
	mat.append((int(a),int(b),int(c)))

mat = np.array(mat).reshape(3,3)


num = int(input())
ball=[]
for i in range(num):
  ball.append(int(input()))

ball = set(ball)

for h in range(3):
  x = set(mat[h,:])
  res = ball.intersection(x) == x
  if res:
    print(res)
    exit()

for w in range(3):
  x = set(mat[:, w])
  res = ball.intersection(x) == x
  if res:
    print(res)
    exit()

x = {mat[0,0],mat[1,1], mat[2,2]}
res = ball.intersection(x) == x
if res:
  print(res)
  exit()

x = {mat[2,0],mat[1,1], mat[0,2]}  
res = ball.intersection(x) == x
if res:
  print(res)
  exit()
  
print(res)

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = []
for i in range(N):
	b.append(int(input()))
	
yoko = A
tate = [[], [], []]
for row in A:
	for i in range(3):
		tate[i].append(row[i])
naname = [[A[0][0], A[1][1], A[2][2]]]

all = yoko + tate + naname


chk = 0
for kumi in all:
	for i in range(3):
		if kumi[0] in b:
			chk += 1
	if chk == 3:
		print("Yes")
		break

if chk != 3:
	print("No")

Submission status: Wrong Answer

Solution code:
row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
num=int(input())
list=[int(input()) for i in range(num)]

for n in list:
 if n in row1:
  row1[row1.index(n)]=0
 elif n in row2:
  row2[row2.index(n)]=0
 elif n in row3:
  row3[row3.index(n)]=0

if row1.count(0) == 3 or row2.count(0) or row3.count(0):
  print('Yes')
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row2[1] == 0:
  if row1[0] == 0 and row3[2] == 0:
    print('Yes')
  elif row1[2] == 0 and row3[0] == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

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

N = int(input())

for n in range(N):
    b = int(input())
    for i in range(3):
        for l in range(3):
            if A[i][l] == b:
                A[i][l] = 0
                
if (A[0][0] == 0 and A[0][1] ==0 and A[0][2]) or (A[1][0] == 0 and A[1][1] ==0 and A[1][2]) or (A[2][0] == 0 and A[2][1] ==0 and A[2][2]) or (A[0][0] == 0 and A[1][0] ==0 and A[2][0]) or (A[0][1] == 0 and A[1][1] ==0 and A[2][1]) or(A[0][2] == 0 and A[1][2] ==0 and A[2][2]) or (A[0][0] == 0 and A[1][1] ==0 and A[2][2]):
    print("Yes")
else:
    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 _ in range(N)]

cnt1 = 0
for i in A1:
    if i in b:
        cnt1 += 1
    if cnt1 == 3:
        flag1 = 1
    else:
        flag1 = 0

cnt2 = 0
for i in A2:
    if i in b:
        cnt2 += 1
    if cnt2 == 3:
        flag2 = 1
    else:
        flag2 = 0

cnt3 = 0
for i in A3:
    if i in b:
        cnt3 += 1
    if cnt3 == 3:
        flag3 = 1
    else:
        flag3 = 0

cnt4 = 0
for i in [A1[0], A2[1], A3[2]]:
    if i in b:
        cnt4 += 1
    if cnt4 == 3:
        flag4 = 1
    else:
        flag4 = 0

cnt5 = 0
for i in [A1[2], A2[1], A3[0]]:
    if i in b:
        cnt5 += 1
    if cnt5 == 3:
        flag5 = 1
    else:
        flag5 = 0


if flag1 == 1 or flag2 == 1 or flag3 == 3 or flag4 == 1 or flag5 == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
lists = [[0 for i in range(3)] for j in range(3)]

for i in range(3):
    b = input().split()
    for j in range(3):
        lists[i][j] = int(b[j])
N = int(input())

for i in range(N):
    c = int(input())
    for j in range(3):
        for k in range(3):
            if lists[j][k] == c:
                lists[j][k] = 0

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

Submission status: Wrong Answer

Solution code:
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))

n = int(input())
li_call = []
for i in range(n):
  li_call.append(int(input()))
for i in range(n):
  for j in range(3):
    if li_a[j] == li_call[i]:
      li_a[j] = 0
  for k in range(3):
    if li_b[k] == li_call[i]:
      li_b[k] = 0
  for l in range(3):
    if li_c[l] == li_call[i]:
      li_c[l] = 0
li_o = 0
li_d = [li_a[0], li_b[0], li_c[0]]
li_e = [li_a[1], li_b[1], li_c[1]]
li_f = [li_a[2], li_b[2], li_c[2]]
li_g = [li_a[0], li_b[1], li_c[2]]
li_h = [li_a[2], li_b[1], li_c[0]]
if li_a == li_o or li_b == li_o or li_c == li_o or li_d == li_o or li_e == li_o or li_f == li_o or li_g == li_o or li_h == [0, 0, 0]:
  print("Yes")
else:
  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_lst = [int(input()) for _ in range(n)]
a_lst = a1 + a2 + a3

for i in range(len(b_lst)):
    if b_lst[i] in a_lst:
        a_lst[a_lst.index(b_lst[i])] = 0

for i in range(3):
    if a_lst[i] == a_lst[i+3] == a_lst[i+6] == 0:
        print("Yes")
        break
    elif a_lst[3*i] == a_lst[3*i+1] == a_lst[3*i+2] == 0:
        print("Yes")
        break
    elif a_lst[2] == a_lst[4] == a_lst[6] == 0 or a_lst[0] == a_lst[4] == a_lst[8] == 0:
        print("Yes")
        break
    else:
        print("No")
        break

Submission status: Wrong Answer

Solution code:
A1,A2,A3=map(int, input().split())
A4,A5,A6=map(int, input().split())
A7,A8,A9=map(int, input().split())
N=int(input()) 
b = [int(input()) for _ in range(N)]
#A=[A11,A12,A13,A21,A22,A23,A31,A32,A33]
cnt1=0
cnt2=0
cnt3=0
cnt4=0
cnt5=0
cnt6=0
cnt7=0
cnt8=0
cnt9=0
for i in range(N):
	if b[i]==A1:
		cnt1+=1
	elif b[i]==A2:
		cnt2+=1
	elif b[i]==A3:
		cnt3+=1
	elif b[i]==A4:
		cnt4+=1
	elif b[i]==A5:
		cnt5+=1
	elif b[i]==A6:
		cnt6+=1
	elif b[i]==A7:
		cnt7+=1
	elif b[i]==A8:
		cnt8+=1
	elif b[i]==A9:
		cnt9+=1
yes=0
if cnt1!=0:
	if (cnt2!=0 and cnt3!=0)or(cnt4!=0 and cnt7!=0)or(cnt5!=0 and cnt9!=0):
		yes+=1
elif cnt2!=0:
	if (cnt5!=0 and cnt8!=0):
		yes+=1
elif cnt3!=0:
	if (cnt6!=0 and cnt9!=0)or(cnt5!=0 and cnt7!=0):
		yes+=1
elif cnt4!=0:
	if (cnt5!=0 and cnt6!=0):
		yes+=1
elif cnt7!=0:
	if (cnt8!=0 and cnt9!=0):
		yes+=1
if yes!=0:
	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 = [int(input()) for i in range(n)]

c = [[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j] = 1
ans = False

if c[0][0] == 1 & c[0][1] == 1 & c[0][2] == 1:
    ans = True
if c[1][0] == 1 & c[1][1] == 1 & c[1][2] == 1:
    ans = True
if c[2][0] == 1 & c[2][1] == 1 & c[2][2] == 1:
    ans = True
if c[0][0] == 1 & c[1][0] == 1 & c[2][0] == 1:
    ans = True
if c[0][1] == 1 & c[1][1] == 1 & c[2][1] == 1:
    ans = True
if c[0][2] == 1 & c[1][2] == 1 & c[2][2] == 1:
    ans = True
if c[0][0] == 1 & c[1][1] == 1 & c[2][2] == 1:
    ans = True
if c[2][0] == 1 & c[1][1] == 1 & c[0][2] == 1:
    ans = True

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

Submission status: Wrong Answer

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

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


result = 'No'

for i in range(3):
    if set(A[i]) in set(b):
        result = 'Yes'

for i in range(3):
    if set([A[0][i], A[1][i], A[2][i]]) <= set(b):
        result = 'Yes'

if set([A[0][0], A[1][1], A[2][2]]) <= set(b):
    result = 'Yes'

if set([A[0][2], A[1][1], A[0][2]]) <= set(b):
    result = 'Yes'

print(result)

Submission status: Wrong Answer

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


def main(A, N, lst_b):
    
    matrix_result = [[False]*3 for i in range(3)]
    flag_bingo = False

    for b in lst_b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    matrix_result[i][j] = True
        
    for i in range(3):
        # check tate
        if (matrix_result[0][i] and matrix_result[1][i] and matrix_result[2][i]):
            flag_bingo = True
        # check yoko
        if (matrix_result[i][0] and matrix_result[i][1] and matrix_result[i][2]):
            flag_bingo = True
    
    # check naname
    if (matrix_result[0][0] and matrix_result[1][1] and matrix_result[2][2]):
        flag_bingo = True
    elif (matrix_result[0][2] and matrix_result[1][1] and matrix_result[2][0]):
        flag_bingo = True

    print(matrix_result)
    
    if flag_bingo: return "Yes"
    else         : return "No"
    

if __name__ == "__main__":

    answer = main(A, N, lst_b)
    print(answer)

Submission status: Wrong Answer

Solution code:
import sys
Ar1 = list(map(int, input().split()))
Ar2 = list(map(int, input().split()))
Ar3 = list(map(int, input().split()))
N = int(input())
b = []

Ac1 = [Ar1[0], Ar2[0], Ar3[0]]
Ac2 = [Ar1[1], Ar2[1], Ar3[1]]
Ac3 = [Ar1[2], Ar2[2], Ar3[2]]

naname1 = [Ar1[0], Ar2[1], Ar3[2]]
naname2 = [Ar1[2], Ar2[1], Ar3[1]]

for i in range(N) :
  b.append(int(input()))
  
for lines in [Ar1, Ar2, Ar3, Ac1, Ac2, Ac3, naname1, naname2] :
  if lines[0] in b and lines[1] in b and lines[2] in b :
    print("Yes")
    sys.exit()
  else :
    next
    
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]"):
    bingo_arr = [
        A[0], A[1], A[2],
        [A[0][0], A[1][0], A[2][0]], [A[0][1], A[1][1], A[2][1]], [A[0][2], A[1][2], A[2][2]],
        [A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]
    ]
    for bingo in bingo_arr:
        for i in bingo:
            if i not in b:
                break
            print(YES)
            return
    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:
import sys
a1 = list(map(str,input().split()))
a2 = list(map(str,input().split()))
a3 = list(map(str,input().split()))
M=int(input())
N = "N"
if M <= 2:
    print('No')
    sys.exit()

Num=[] #appendのために宣言が必要
while True:
    try:
        Num.append(input())

    except:
        break;

A1= ["N" if Num.count(i)!=0 else i for i in a1]
A2= ["N" if Num.count(i)!=0 else i for i in a2]
A3= ["N" if Num.count(i)!=0 else i for i in a3]
print(A1,A2,A3,Num)
if A1[0] == N and A1[1] == N and A1[2] == N :
    print("Yes")
elif A2[0] == N and A2[1] == N and A2[2] == N :
    print("Yes")
elif A3[0] == N and A3[1] == N and A3[2] == N :
    print("Yes")
elif A1[0] == N and A2[0] == N and A3[0] == N :
    print("Yes")
elif A1[1] == N and A2[1] == N and A3[2] == N :
    print("Yes")
elif A1[2] == N and A2[2] == N and A3[2] == N :
    print("Yes")
elif A1[0] == N and A2[1] == N and A3[2] == N :
    print("Yes")
elif A1[2] == N and A2[1] == N and A3[0] == N :
    print("Yes")
else:
    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()))
A = A1 + A2 + A3

N = int(input())

# 印をつける
for i in range(N):
    b = int(input())
    
    for index in range(len(A)):
        a = A[index]
        if a == b:
            A[index] = 0     # 0を印とする

def isExistTatePair():
    for i in range(3):
        sum = 0
        for j in range(3):
            sum += A[3 * j + i]
        if sum == 0:
            return True
    return False

def isExistYokoPair():
    for i in range(3):
        sum = 0
        for j in range(3):
            sum += A[3 * i + j]
        if sum == 0:
            return True
    return False

def isExistNanamePair():
    sum = 0
    for i in range(3):
        sum += A[3 * i + i]
    if sum == 0:
        return True
    
    sum = 0
    for i in range(3):
        sum += A[3 * (i + 1) - i]
    if sum == 0:
        return True
    return False

isExistPair = isExistTatePair() or isExistYokoPair() or isExistNanamePair()
print('Yes' if isExistPair else 'No')

Submission status: Wrong Answer

Solution code:
a=[0]
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
print(a)
n=int(input())
for i in range(n):
    b=int(input())
    for k in range(10):
        if a[k]==b:
            a[k]=0
print(a)
t="No"
if a[1]==0 and a[2]==0 and a[3]==0:
    t="Yes"
if a[4]==0 and a[5]==0 and a[6]==0:
    t="Yes"
if a[7]==0 and a[8]==0 and a[9]==0:
    t="Yes"
if a[1]==0 and a[4]==0 and a[7]==0:
    t="Yes"
if a[2]==0 and a[5]==0 and a[8]==0:
    t="Yes"
if a[3]==0 and a[6]==0 and a[9]==0:
    t="Yes"
if a[1]==0 and a[5]==0 and a[9]==0:
    t="Yes"
if a[3]==0 and a[5]==0 and a[7]==0:
    t="Yes"

print(t)

Submission status: Wrong Answer

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

if (a11 in num and a12 in num and a13 in num) == True:
    print('Yes')
elif (a21 in num and a22 in num and a23 in num) == True:
    print('Yes')
elif (a31 in num and a32 in num and a33 in num) == True:
    print('Yes')
elif (a11 in num and a21 in num and a31 in num) == True:
    print('Yes')
elif (a12 in num and a22 in num and a32 in num) == True:
    print('Yes')
elif (a13 in num and a23 in num and a33 in num) == True:
    print('Yes')
elif (a11 in num and a22 in num and a33 in num) == True:
    print('Yes')
elif (a31 in num and a22 in num and a33 in num) == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = [input().split() for x in range(3)]
N = int(input())
B = [int(input()) for y in range(N)]
index1 = 0
index2 = 0
count1 = 0
count2 = 0
Match = {}
for number in B:
  for n in A:
    for m in n:
      if number == m:
        March['A[count1][count2]'] = m
      count2 += 1
    count1 += 1
    count2 = 0

Submission status: Wrong Answer

Solution code:
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst3 = list(map(int, input().split()))
bng1=[0, 0, 0]
bng2=[0, 0, 0]
bng3=[0, 0, 0]
n = int(input())
for i in range(n):
    b = int(input())
    for i in range(len(lst1)):
        if b == lst1[i]:
            bng1[i] = 1
            break
    for ii in range(len(lst2)):
        if b == lst2[ii]:
            bng2[ii] = 1
            break
    for iii in range(len(lst3)):
        if b == lst3[iii]:
            bng3[iii] = 1
            break
    if '0' in bng1 == False or '0' in bng2 == False or '0' in bng3 == False:
        print('Yes')
        exit()
    elif bng1[0] * bng2[1] * bng3[2] != 0 or  bng1[2] * bng2[1] * bng3[0] != 0:
        print('Yes')
        exit()
    elif bng1[0] * bng2[0] * bng3[0] != 0 or  bng1[1] * bng2[1] * bng3[1] != 0 or  bng1[2] * bng2[2] * bng3[2] != 0:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

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

from fractions import gcd
import math
from math import ceil,floor
import collections

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

def func(a):
   return tmp

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

ans="No"

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

print(A)

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

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

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

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

print(ans)

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 j in range(3):
        for k in range(3):
            if b[i]==A[j][k]:
                A[j][k]=0

List=[]
                
sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[i][j]
    List.append(sum)

sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[j][i]
    List.append(sum)

sum = 0
for j in range(3):
    sum=sum+A[i][i]
List.append(sum)

sum= 0
for i in range(3):
    sum =sum+A[i][2-i]
List.append(sum)

ans=0
for i in range(len(List)):
    if List[i]==0:
        ans = ans +1

if ans !=0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import collections
L = list(map(int,input().split()))
L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))
LL = L + L1 + L2
N = int(input())
M = []
for i in range(N):
    ML = input()
    M.append(int(ML))
def common_member(a, b): 
    a_set = set(a) 
    b_set = set(b) 
    if (a_set & b_set): 
        return "Yes"
    else: 
        return "No"
print(common_member(M,LL))

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

flag=0
n=int(input())
for k in range(0,n):
    e=int(input())
    for i in range(0,3):    
        if e==a[i]:
            a[i]=0
        if e==b[i]:
            b[i]=0
        if e==c[i]:
            c[i]=0

for j in range(0,3):
    if a[j]==b[j] and b[j]==c[j]:
        if c[j]==0:
            flag==1
            
if a[0]==a[1] and a[1]==a[2]:
    if a[0]==0:
        flag=1
if b[0]==b[1] and b[1]==b[2]:
    if b[0]==0:
        flag=1
if c[0]==c[1] and c[1]==c[2]:
    if c[0]==0:
        flag=1

if a[0]==b[1] and b[1]==c[2]:
    if c[2]==0:
        flag=1

if a[2]==b[1] and b[1]==c[0]:
    if c[2]==0:
        flag=1

if flag==1:
    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][2 - i] for i 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:
a = []
for i in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
b = [int(input()) for i in range(n)]

c = [[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j] = 1
ans = False

if c[0][0] == 1 & c[0][1] == 1 & c[0][2] == 1:
    ans = True
elif c[1][0] == 1 & c[1][1] == 1 & c[1][2] == 1:
    ans = True
elif c[2][0] == 1 & c[2][1] == 1 & c[2][2] == 1:
    ans = True
elif c[0][0] == 1 & c[1][0] == 1 & c[2][0] == 1:
    ans = True
elif c[0][1] == 1 & c[1][1] == 1 & c[2][1] == 1:
    ans = True
elif c[0][2] == 1 & c[1][2] == 1 & c[2][2] == 1:
    ans = True
elif c[0][0] == 1 & c[1][1] == 1 & c[2][2] == 1:
    ans = True
elif c[2][0] == 1 & c[1][1] == 1 & c[0][2] == 1:
    ans = True

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def a():
    A = []
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[int(input())] = 1

    B = list(map(lambda x:d[x],A))

    if B[4]:
        if B[0] * B[8] + B[2] * B[6]:
            return 1
    
    for i in range(3):
        if sum(B[i*3:i*3+3]) == 3:
            return 1
        if sum(B[i::2]) == 3:
            return 1
    
    return 0

print(["No","Yes"][a()])

Submission status: Wrong Answer

Solution code:
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
# print(a)
# print(b)
# print(c)
n = int(input())
d = [int(input()) for i in range(n)]
# print(d)

if (a[0]in d) and (a[1]in d) and(a[2]in d):
    print("Yes")
    exit()
if (b[0]in d)and(b[1]in d)and(b[2]in d):
    print("Yes")
    exit()
if (c[0]in d)and(c[1]in d)and(c[2]in d):
    print("Yes")
    exit()
if(a[2]in d)and(b[1]in d)and(c[0]in d):
    print("Yes")
    exit()
if(a[0]in d)and(b[1]in d)and(c[2]in d):
    print("Yes")
    exit()
else:
    print("No")

Submission status: Wrong Answer

Solution code:
print("Yes")

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

z1=[]
z2=[]
z3=[]
z4=[]
z5=[]
z6=[]
z7=[]
z8=[]
z1.append(a)
z1.append(b)
z1.append(c)

z2.append(d)
z2.append(e)
z2.append(f)

z3.append(g)
z3.append(h)
z3.append(i)

z4.append(a)
z4.append(d)
z4.append(g)

z5.append(b)
z5.append(e)
z5.append(h)

z6.append(c)
z6.append(f)
z6.append(i)

z7.append(a)
z7.append(e)
z7.append(i)

z8.append(c)
z8.append(e)
z8.append(g)

n=int(input())
for i in range(n):
    x=int(input())
    if x in z1:z1.remove(x)
    if x in z2:z2.remove(x)
    if x in z3:z3.remove(x)
    if x in z4:z4.remove(x)
    if x in z5:z5.remove(x)
    if x in z6:z6.remove(x)
    if x in z7:z7.remove(x)
    if x in z8:z8.remove(x)

if len(z1)==0 and len(z2)==0 and len(z3)==0 and len(z4)==0 and len(z5)==0 and len(z6)==0 and len(z7)==0 and len(z8)==0:
    print("Yes")
else:
    print("No")