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

flg = False
for i in range(3):
  if sum(array[i]) == 0:
    flg = True
for i in range(3):
  if (array[i][0] + array[i][1] + array[i][2]) == 0:
    flg = True
if (array[0][0] + array[1][1] + array[2][2]) == 0:
  flg = True
if (array[2][0] + array[1][1] + array[0][2]) == 0:
  flg = True
  
if flg:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:


bingo = []
for count in range(0,3):
    A = list(map(int,input().split()))
    bingo.append(A)

bingo1 = [0] * 3
bingo2 = [0] * 3
bingo3 = [0] * 3
N = int(input())

for count in range(0,N):
    inp = int(input())
    for bi in bingo:
        for count2 in range(3):
            if bi[count2] == inp:
                if count2 == 0:
                    bingo1[count2] = 1
                if count2 == 1:
                    bingo2[count2] = 1
                if count2 ==2 :
                    bingo3[count2] = 1
bingF = False
#bingo判定
for count in range(3):
    #横
    if bingo1[count] == 1 and bingo2[count] == 1 and bingo3[count] == 1:
        bingF = True
#縦
if bingo1[0] == 1 and bingo1[1] == 1 and bingo1[2] == 1:
    bingF = True
if bingo2[0] == 1 and bingo2[1] == 1 and bingo2[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo3[1] == 1 and bingo3[2] == 1:
    bingF = True

#斜め
if bingo1[0] == 1 and bingo2[1] == 1 and bingo3[2] == 1:
    bingF = True
if bingo3[0] == 1 and bingo2[1] == 1 and bingo1[2] == 1:
    bingF = True

if bingF == False:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

sign = [[0]*3]*3

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

result = []
for i in range(3):
    result.append(sign[i][0] + sign[i][1] + sign[i][2])
    result.append(sign[0][i] + sign[1][i] + sign[2][i])
result.append(sign[0][0] + sign[1][1] + sign[2][2])
result.append(sign[0][2] + sign[1][1] + sign[0][2])

def f(result):
    for num in result:
        if num == 3:
            return("Yes")
    return("No")

print(f(result))

Submission status: Wrong Answer

Solution code:
#!python3.4.3

a = []
result = []

for i in range(3):
  a.append(list(map(int, input().split(' '))))
  
a_flat = sum(a, [])
n = int(input())

for _ in range(n):
  b = int(input())
  
  if b in a_flat:
    result.append(a_flat.index(b))

# print(result)

if result and ([0, 1, 2] or [3, 4, 5] or [6, 7, 8] or [0, 3, 4] or [1, 4, 7] or [2, 5, 8] or [0, 4, 8] or [2, 4, 6] in result):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
from collections import deque
def main():
    a_1 = [int(t)for t in input().split()]
    a_2 = [int(t)for t in input().split()]
    a_3 = [int(t)for t in input().split()]

    a = [a_1,a_2,a_3]

    card = np.array(a)

    n = int(input())

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

    result = np.zeros((3,3),np.int)!=0

    for i in b:
        t = card==i
        result |= t

    rest = result.T
    c = result[0].all() or result[1].all() or result[2].all()
    r = rest[0].all() or rest[1].all() or rest[2].all()

    sl = result[0][0] and result[1][1] and result[2][2]
    bs = result[2][0] and result[1][1] and result[0][2]

    print("yes" if c or r or sl or bs else "no")
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
al = input().split()
bl = input().split()
cl = input().split()
al = [int(i) for i in al]
bl = [int(i) for i in bl]
cl = [int(i) for i in cl]
h1 = [0,0,0]
h2 = [0,0,0]
h3 = [0,0,0]
n = int(input())
for h in range(n):
  m = int(input())
  ac = 0
  bc = 0
  cc = 0
  for i in al:
    if i == m:
      h1[ac] = 1
    ac += 1
  for i in bl:
    if i == m:
      h2[bc] = 1
    bc += 1
  for i in cl:
    if i == m:
      h3[cc] = 1
    cc += 1
if (h1 or h2 or h3) == [1,1,1]:
  print("Yes")
elif h1[0]==1 and h2[0]==1 and h3[0]:
  print("Yes")
elif h1[1]==1 and h2[1]==1 and h3[1]:
  print("Yes")
elif h1[2]==1 and h2[2]==1 and h3[2]:
  print("Yes")
elif h1[0]==1 and h2[1]==1 and h3[2]:
  print("Yes")
elif h1[2]==1 and h2[1]==1 and h3[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=[]

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

allnum=[]
allnum.append(a1)
allnum.append(a2)
allnum.append(a3)


bingo=[[0,0,0],[0,0,0],[0,0,0]]

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

for i in range(3):
    if(bingo[i][0] and bingo[i][1] and bingo[i][2]):
        print("Yes")
        exit()
for i in range(3):
    if(bingo[0][i] and bingo[1][i] and bingo[2][i]):
        print("Yes")
        exit()
if(bingo[0][0] and bingo[1][1] and bingo[2][2]):
    print("Yes")
    exit()

if(bingo[2][1] and bingo[1][1] and bingo[1][2]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

N = int(input())

s = [int(input()) for i in range(N)]


if len(list(set(a) & set(s))) or len(list(set(b) & set(s))) or len(list(set(c) & set(s))) == 3:
    print('Yes')

elif len(list(set([a[0],b[1],c[2]]) & set(s))) or len(list(set([a[2],b[1],c[0]]) & set(s))) == 3:
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
rows = []
for i in range(3):
    row = [int(x) for x in input().split()]
    rows.append(row)

N = int(input())
choice = []
for j in range(N):
    choice.append(int(input()))


for row in rows:
    match = [c for c in choice if c in row]

    if (len(match) >= 3):
        print("Yes")
        break

columns = []
for k in range(3):
    column = [rows[l][k] for l in range(3)]
    columns.append(column)

for column in columns:
    match = [c for c in choice if c in column]

    if (len(match) >= 3):
        print("Yes")
        break

left = []
for m in range(3):
    left.append(rows[m][m])

right = []
for n in range(3):
    for o in range(3)[::-1]:
        right.append(rows[n][o])

match_left = [c for c in choice if c in left]
match_right = [c for c in choice if c in right]

if (len(match_left) >= 3):
    print("Yes")
elif (len(match_right) >= 3):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

s = 0

for i in range(3):
    if r[i][0] == r[i][1] == r[i][2] == 1:
        s += 1
        break
    elif r[0][i] == r[1][i] == r[2][i] == 1:
        s += 1
        break

if r[0][0] == r[1][1] == r[2][2] == 1:
    s += 1
elif r[2][0] == r[1][1] == r[0][2] == 1:
    s += 1

if s > 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()))
A = []
for a in a1:
  A.append([a, False])
for a in a2:
  A.append([a, False])
for a in a3:
  A.append([a, False])

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

for i, a in enumerate(A):
  if (a[0] in B):
    A[i][1] = True

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

print(result)

Submission status: Wrong Answer

Solution code:
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for _ in range(n):
    b.append(int(input()))
b = set(b)
row = []
col = []
diag = []
for i in range(3):
    tmp1 = []
    tmp2 = []
    for j in range(3):
        tmp1.append(a[i][j])
        tmp2.append(a[j][i])
    row.append(set(tmp1))
    col.append(set(tmp2))

tmp3 = []
tmp4 = []
for j in range(3):
    tmp3.append(a[i][i])
    tmp4.append(a[i][3-i])
diag.append(set(tmp3))
diag.append(set(tmp4))

bingo = False
for i in range(3):
    if row[i] <= b or col[i] <= b:
        bingo = True
for i in range(2):
    if diag[i] <= b:
        bingo = True

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

Submission status: Wrong Answer

Solution code:
l=[[]]*3
for k in range(3):
  l[k]=list(map(int,input().split()))
n=int(input())
ll=[[0,0,0]]*3
for k in range(n):
  i=int(input())
  for j in range(3):
    if i in l[j]:
      ll[j][l[j].index(i)]=1
a=0
if ll[0][0]==1:
  if ll[0][1]==1 and ll[0][2]==1:
    print("Yes")
    a=1
  elif ll[1][1]==1 and ll[2][2]==1:
    print("Yes")
    a=1
  elif ll[1][0]==1 and ll[2][0]==1:
    print("Yes")
    a=1
elif ll[0][1]==1 and ll[1][1]==1 and ll[2][1]==1:
  print("Yes")
  a=1
elif ll[0][2]==1:
  if ll[1][1]==1 and ll[2][0]==1:
    print("Yes")
    a=1
  elif ll[1][2]==1 and ll[2][2]==1:
    print("Yes")
    a=1
elif ll[1][0]==1:
  if ll[1][1]==1 and ll[1][2]==1:
    print("Yes")
    a=1
elif ll[2][0]==1:
  if ll[2][1]==1 and ll[2][2]==1:
    print("Yes")
    a=1
if a==0:
  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)]

emp = [[0] * 3 for _ in range(3)]
#print(n, b)

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

x = [-1, 0, 1, -1, -1, -1, -1, 1]
y = [-1, -1, -1, -1, 0, 1, -1, -1]
dx = [0, 0, 0, 1, 1, 1, 1, -1]
dy = [1, 1, 1, 0, 0, 0, 1, 1]

flag = True
ans = False

for i in range(8) :
    xx = x[i]
    yy = y[i]
    flag = True
    for j in range(3) :
        xx += dx[i]
        yy += dy[i]
        if emp[xx][yy] != 1 :
            flag = False
            break
    if flag == True :
        ans = True
if ans :
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

def check(A):
    for i in range(3):
        if A[i,0] == 0 and A[i,1] == 0 and A[i,2] == 0:
            return True
        if A[0,i] == 0 and A[1,i] == 0 and A[2,i] == 0:
            return True
    if A[0,0] == 0 and A[1,1] == 0 and A[2,2] == 0:
        return True
    if A[0,2] == 0 and A[1,1] == 0 and A[2,0] == 0:
        return True

    return False



a = list(map(int, input().split()))
A = a
a = list(map(int, input().split()))
A = np.vstack((A, a))
a = list(map(int, input().split()))
A = np.vstack((A, a))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

for i in range(N):
    for m in range(3):
        for n in range(3):
            if b[i] == A[m,n]:
                A[m,n] = 0

if check(A):
    print("yes")
else:
    print("no")

Submission status: Wrong Answer

Solution code:
import itertools

bingo = []

for _ in range(3):
    array = list(map(int, input().split()))
    bingo.append(array)

bingo = list(itertools.chain.from_iterable(bingo))

bingo_bi = [False for _ in range(9)]

n = int(input())

nums = []

for _ in range(n):
    num = int(input())
    if num in bingo:
        bingo_bi[bingo.index(num)] = True

correct = [True, True, True]

if bingo_bi[0:3] == correct and bingo_bi[3:6] == correct and bingo_bi[6:9] == correct:
    print('Yes')
elif bingo_bi[0::3] == correct and bingo_bi[1::3] == correct and bingo_bi[2::3] == correct:
    print('Yes')
elif bingo_bi[0] == True and bingo_bi[4] == True and bingo_bi[8] == True:
    print('Yes')
elif bingo_bi[2:8:2] == correct:
    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())
bingo = [[0 for i in range(3)] for i in range(3)]
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                bingo[j][k] = 1
if sum(bingo[0])==3 or sum(bingo[0])==3 or sum(bingo[0])==3 or (bingo[0][0] and bingo[1][0] and bingo[2][0]) or (bingo[0][1] and bingo[1][1] and bingo[2][1]) or (bingo[0][2] and bingo[1][2] and bingo[2][2]) or (bingo[0][0] and bingo[1][1] and bingo[2][2]) or (bingo[0][2] and bingo[1][1] and bingo[2][0]):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a11,a12,a13=(int(x) for x in input().split())
a21,a22,a23=(int(x) for x in input().split())
a31,a32,a33=(int(x) for x in input().split())
n=int(input())
list=[]
for i in range(n):
	list.append(int(input()))
s=set(list)

def ch(a,b,c,s):
	print(a,b,c,s)
	k=0
	if a in s:
		if b in s:
			if c in s:
				k=1
	return k
co=0
co+=ch(a11,a12,a13,s)
co+=ch(a21,a22,a23,s)
co+=ch(a31,a32,a33,s)
co+=ch(a11,a21,a31,s)
co+=ch(a12,a22,a32,s)
co+=ch(a13,a23,a33,s)
co+=ch(a11,a22,a33,s)
co+=ch(a13,a22,a31,s)
if co>0:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

N = int(input())
Flag = False
for k in range(N):
    temp = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == temp:
                A[i][j] = 0
            else:
                next

if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
    Flag = True
elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
    Flag = True
elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    Flag = True
elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
    Flag = True
elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
    Flag = True
elif A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0:
    Flag = True
elif A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0:
    Flag = True


if Flag == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
Flg = "No"
A = [[0]*3]*3
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())
    
for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

print(Flg)

Submission status: Wrong Answer

Solution code:
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]

B1 = [0,0,0]
B2 = [0,0,0]
B3 = [0,0,0]

n = input()
N = int(n)

for i in range(N):
  B = input()
  b = int(B)
  if b == A1[0]:
    B1[0] = 1
  elif b == A1[1]:
    B1[1] = 1
  elif b == A1[2]:
    B1[2] = 1
  elif b == A2[0]:
    B2[0] = 1
  elif b == A2[1]:
    B2[1] = 1
  elif b == A2[2]:
    B2[2] = 1
  elif b == A3[0]:
    B3[0] = 1
  elif b == A3[1]:
    B3[1] = 1
  elif b == A3[2]:
    B3[2] = 1

#print(B1)
#print(B2)
#print(B3)
    
ans="No"

if B1[0]==1:
  if B1[1]==1:
    if B1[2]==1:
      ans = "Yes"
if B2[0]==1:
  if B2[1]==1:
    if B2[2]==1:
      ans = "Yes"
if B3[0]==1:
  if B3[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[0]==1:
    if B3[0]==1:
      ans = "Yes"
if B1[1]==1:
  if B2[1]==1:
    if B3[1]==1:
      ans = "Yes"
if B1[1]==1:
  if B2[1]==1:
    if B3[1]==1:
      ans = "Yes"
if B1[0]==1:
  if B2[1]==1:
    if B3[2]==1:
      ans = "Yes"
if B1[2]==1:
  if B2[1]==1:
    if B3[0]==1:
      ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

n = int(input())
b_s = []
for i in range(n):
    b_s.append(int(input()))
ans = "No"


for i in range(n):
    for j in range(3):
        for k in range(3):
            if b_s[i] == bingo[j][k]:
                bingo[j][k] = "o"

if bingo[1][1] == "o":
    if bingo[0][0] == "o" and bingo[2][2] == "o":
        ans = "Yes"
    elif bingo[0][2] == "o" and bingo[2][1] == "o":
        ans = "Yes"
    elif bingo[1][0] == "o" and bingo[1][2] == "o":
        ans = "Yes"
    elif bingo[0][1] == "o" and bingo[2][1] == "o":
        ans = "Yes"

elif bingo[1][1] != "o":
    if bingo[0][0] == "o" and bingo[0][1] == "o" and bingo[0][2] == "o":
        ans = "Yes"
    if bingo[0][0] == "o" and bingo[1][0] == "o" and bingo[2][0] == "o":
        ans = "Yes"
    if bingo[0][2] == "o" and bingo[1][2] == "o" and bingo[2][2] == "o":
        ans = "Yes"
    if bingo[2][0] == "o" and bingo[2][1] == "o" and bingo[2][2] == "o":
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

#print(bingo)
#print(number)
check=[0,0,0,0,0,0,0,0,0]
ans=0
for i in range(N):
    for j in range(3):
        for k in range(3):
            if number[i]==bingo[j][k]:
                check[3*j+k]=1
                
                
                
for i in range(3):
    if check[0+3*i]==check[1+3*i]==check[2+3*i]==1:
        ans=1
    if check[j]==check[j+3]==check[j+6]==1:
        ans=1
        
if check[0]==check[4]==check[8]==1:
    ans=1
if check[2]==check[4]==check[6]==1: 
    ans=1
    
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a=[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):
        if int(a[i][j]) in b:
            a[i][j]=999
#印をつける
c=0
for i in range(3):
    if a[i][0]==999 and a[i][1]==999 and a[i][2]==999:
        c+=1
    elif a[0][i]==999 and a[1][i]==999 and a[2][i]==999:
        c+=1
    elif a[0][0]==999 and a[1][1]==999 and a[2][2]==999:
        c+=1
    elif a[0][2]==999 and a[2][2]==999 and a[2][0]==999:
        c+=1
if c==0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
x=[[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 a[j][k]==b:
        x[j][k]=1

ans='No'
for i in range(3):
  if sum(x[j])==3:
    ans='Yes'
for i in range(3):
  if x[i][0]+x[i][1]+x[i][2]==3:
    ans='Yes'
if x[0][0]+x[1][1]+x[2][2]==3:
  ans='Yes'
if x[2][0]+x[1][1]+x[0][2]==3:
  ans='Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
A_list = []

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

N = int(input())

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

large_flag = 0
small_flag = 0

for i in range(3):
    tmp = [A_list[i], A_list[i + 3], A_list[i + 6]]
    for val in tmp:
        if val in b_list:
            small_flag += 1
            if small_flag == 3:
                print("Yes")
                large_flag += 1
                break
            else:
                continue
        else:
            break

if large_flag == 0:
    small_flag = 0
    for i in range(3):
        tmp = [A_list[i * 3], A_list[i * 3 + 1], A_list[i * 3 + 2]]
        for val in tmp:
            if val in b_list:
                small_flag += 1
                if small_flag == 3:
                    print("Yes")
                    large_flag += 1
                    break
                else:
                    continue
            else:
                break

if large_flag == 0:
    small_flag = 0
    tmp = [A_list[0], A_list[4], A_list[8]]
    for val in tmp:
        if val in b_list:
            small_flag += 1
            if small_flag == 3:
                print("Yes")
                large_flag += 1
                break
            else:
                continue
        else:
            break

if large_flag == 0:
    small_flag = 0
    tmp = [A_list[2], A_list[4], A_list[6]]
    for val in tmp:
        if val in b_list:
            small_flag += 1
            if small_flag == 3:
                print("Yes")
                large_flag += 1
                break
            else:
                continue
        else:
            break

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

Submission status: Wrong Answer

Solution code:
a1=[int(i) for i in input().split()]
a2=[int(i) for i in input().split()]
a3=[int(i) for i in input().split()]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b: a1[j]=-1
        if a2[j]==b: a1[j]=-1
        if a3[j]==b: a1[j]=-1
print("Yes" if sum(a1)==-3 or sum(a2)==-3 or sum(a3)==-3 or a1[0]+a2[1]+a3[2]==-3 or a1[2]+a2[1]+a3[0]==-3 else "No" )

Submission status: Wrong Answer

Solution code:
list1 = []
for x in range(3):
    list1.append([int(i)for i in input().split()])
n = int(input())
indices = []
for x in range(n):
    val = int(input())
    if val in list1[0]:
        indices.append([list1[0].index(val),0])
    elif val in list1[1]:
        indices.append([list1[1].index(val),1])
    elif val in list1[2]:
        indices.append([list1[2].index(val),2])
    else:
        indices.append(-1)
if [0,0] in indices and [0,1] in indices and [0,2] in indices:
    print("Yes")
elif [1,0] in indices and [1,1] in indices and [1,2] in indices:
    print("Yes")
elif [2,0] in indices and [2,1] in indices and [2,2] in indices:
    print("Yes")
elif [0,0] in indices and [1,0] in indices and [2,0] in indices:
    print("Yes")
elif [0,1] in indices and [1,1] in indices and [2,1] in indices:
    print("Yes")
elif [0,2] in indices and [1,2] in indices and [2,2] in indices:
    print("Yes")
elif [0,0] in indices and [1,1] in indices and [2,2] in indices:
    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())
b = [int(input()) for i in range(n)]

aa = [0] * 8
for i in range(3):
    for j in range(3):
        if bingo[i][j] in b:
            aa[i] += 1
            aa[j+3] += 1
            if i == j:
                aa[-2] += 1
            if i + j == 3:
                aa[-1] += 1
aa[-1] -= 1
if 3 in aa:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

N = int(input())

s = [int(input()) for i in range(N)]

print(a)
print(b)
print(c)
print(s)


if len(list(set(a) & set(s))) or len(list(set(b) & set(s))) or len(list(set(c) & set(s))) == 3:
    print('Yes')

elif len(list(set([a[0],b[1],c[2]]) & set(s))) or len(list(set([a[2],b[1],c[0]]) & set(s))) == 3:
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

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

N = int(input())

for i in range(N):
    b = int(input())
    for j in range(3):
        if b in A[j]:
            idx = A[j].index(b)
            bingo[j][idx] = True

# check
migiue = True
migisita = True
okFlg = False
for i in range(3):
    tate = True
    yoko = True
    for j in range(3):
        if bingo[i][j] == False:
            yoko = False
        if bingo[j][i] == False:
            tate = False
    if tate or yoko:
        print('Yes')
        okFlg = True
        break
    if bingo[i][i] == False:
        migisita = False
    if bingo[-i-1][-i-1] == False:
        migiue = False

if migiue or migisita:
    if okFlg == False:
        print('Yes')
        okFlg=True
if okFlg == False:
    print('No')

Submission status: Wrong Answer

Solution code:
t = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
m = [int(input()) for i in range(n)]
for i in range(3):
        if t[i][0] in m and t[i][1] in m and t[i][2] in m:
            print('Yes')
            break
        elif t[0][i] in m and t[1][i] in m and t[2][i] in m:
            print('Yes')
            break
        elif t[0][0] in m and t[1][1] in m and t[2][2] in m:
            print('Yes')
            break
        elif t[0][2] in m and t[1][1] in m and t[2][0] in m:
            print('Yes')
            break
        else:
            print('No')
            break

Submission status: Wrong Answer

Solution code:
import numpy as np
def resolve_b():
    card = [list(map(int, input().split())) for i in range(3)]
    l = [[0,0,0],[0,0,0],[0,0,0]]
    n = int(input())

    for i in range(n):
        num = int(input())
        for j in range(3):
            for k in range(3):
                if card[j][k] == num:
                    l[j][k] = 1
    nl = np.array(l)

    if sum(l[0]) == 3 or sum(l[1]) == 3 or sum(l[2]) == 3 or sum(l[:][0]) == 3 or sum(nl[:,0])or sum(nl[:,1])or sum(nl[:,2]):
        print("Yes")
    elif (l[0][0] + l[1][1] + l[2][2]) == 3 or (l[0][2] + l[1][1] + l[2][0]) :
        print("Yes")
    else:
        print("No")
resolve_b()

Submission status: Wrong Answer

Solution code:
import numpy as np

a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

list_ = set(a+b+c)
n = int(input())

a = np.array([a, b, c])

for _ in range(n):
  x = int(input())
  if x in list_:
    a = np.where(a==x,0,a)
if np.sum(a==0) < 3:
  print('No')
  quit()

for i in range(3):
  if sum(a[:,i]) == 0:
    print('Yes')
    quit()

for i in range(3):
  if sum(a[i,:]) == 0:
    print('Yes')
    quit()

if a[0,0]+a[1,1]+a[2,2] == 0 or a[0,2]+a[1,1]+a[2,0] == 0:
  print('Yes')

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_all = A1
A_all.extend(A2)
A_all.extend(A3)


N = int(input())


def get_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default
        
for i in range(N):
    b = int(input())
    suffix = get_index(A_all, b)
    if suffix >= 0:
        A_all[suffix] = 0

if A_all[0] + A_all[1] + A_all[2] == 0: print("Yes")
elif A_all[3] + A_all[4] + A_all[5] == 0: print("Yes")
elif A_all[6] + A_all[7] + A_all[8] == 0: print("Yes")
elif A_all[0] + A_all[3] + A_all[6] == 0: print("Yes")
elif A_all[1] + A_all[4] + A_all[7] == 0: print("Yes")
elif A_all[2] + A_all[5] + A_all[8] == 0: print("Yes")
elif A_all[0] + A_all[4] + A_all[8] == 0: print("Yes")
elif A_all[2] + A_all[4] + A_all[5] == 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())
for _ in range(N):
  b = int(input())
  for i in range(3):
    if A1[i] == b:
      A1[i] = 0
  for j in range(3):
    if A2[j] == b:
      A2[j] = 0
  for k in range(3):
    if A3[k] == b:
      A3[k] = 0
print(A1,A2,A3)
if A1[0] == 0:
  if (A1[1]==0 and A1[2]==0) or (A2[0]==0 and A3[0]==0) or (A2[1]==0 and A3[2]==0):
    print('Yes')
    exit()
if A2[0] == 0:
  if (A2[1]==0 and A2[2]==0):
    print('Yes')
    exit()
if A3[0] == 0:
  if (A3[1]==0 and A3[2]==0) or (A2[1]==0 and A1[2]==0):
    print('Yes')
    exit()
if A1[1] == 0:
  if (A2[1]==0 and A3[1]==0):
    print('Yes')
    exit()
if A1[2] == 0:
  if (A2[2]==0 and A3[2]==0):
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

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

def main():
    bingo_map = [[0] * 3 for _ in range(3)]
    number_list = []
    for _ in range(3):
        A, B, C = map(int, input().split())
        number_list.append(A)
        number_list.append(B)
        number_list.append(C)
    N = int(input())
    for _ in range(N):
        b = int(input())
        if b in number_list:
            pos = number_list.index(b)
            bingo_map[pos//3][pos%3] = 1
        else:
            continue
    nagomi = bingo_map[0][0] + bingo_map[1][1] + bingo_map[2][2]
    kugoi  = bingo_map[0][2] + bingo_map[1][1] + bingo_map[2][0]
    nahaku = sum(bingo_map[0])
    shigoro = sum(bingo_map[1])
    hifumi = sum(bingo_map[2])
    nashii = bingo_map[0][0] + bingo_map[1][0] + bingo_map[2][0]
    yagoni = bingo_map[1][0] + bingo_map[1][1] + bingo_map[2][1]
    kuromi = bingo_map[2][0] + bingo_map[2][1] + bingo_map[2][2]
    if nagomi == 3 or kugoi == 3 or nahaku == 3 or shigoro == 3 or hifumi == 3 or nashii == 3 or yagoni == 3 or kuromi == 3:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()