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:
rows = []
for i in range(3):
    row = [int(x) for x in input().split()]
    rows.append(row)


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

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

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


matches = []
for row in rows:
    matches.append([c for c in choice if c in row])

for column in columns:
    matches.append([c for c in choice if c in column])

matches.append([c for c in choice if c in left])
matches.append([c for c in choice if c in right])


isPrinted = False
for match in matches:
    if (len(match) == 3):
        print("Yes")
        isPrinted = True
        break

if (not isPrinted):
    print("No")

Submission status: Wrong Answer

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

d1 = [a[0][0],a[1][1], a[2][2]]
d2 = [a[0][2],a[1][1], a[2][0]]
col1 = [a[0][0],a[0][1], a[0][2]]
col2 = [a[1][0],a[1][1], a[1][2]]
col3 = [a[2][0],a[2][1], a[2][2]]

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

if all(elem in check for elem in d1):
    print("Yes")
elif all(elem in check for elem in d2):
    print("Yes")
elif all(elem in check for elem in col1):
    print("Yes")
elif all(elem in check for elem in col2):
    print("Yes")
elif all(elem in check for elem in col3):
    print("Yes")
elif all(elem in check for elem in a[0]):
    print("Yes")
elif all(elem in check for elem in a[1]):
    print("Yes")
elif all(elem in check for elem in a[2]):
    print("Yes")
else:
    print("No")

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(a_flat)
# print(result)

if result and ([0, 1, 2] or [3, 4, 5] or [6, 7, 8] or [0, 3, 6] 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:
A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=[]
for _ in range(N):
    B.append(int(input()))

# まず横の列を検索する
bingo=False
for i in range(3):
    for j in range(3):
        if not A[i][j] in B:
            break
        if j == 2:
            bingo=True

# 次に縦の列を検索する
for i in range(3):
    for j in range(3):
        if not A[j][i] in B:
            break
        if i == 2:
            bingo=True

# 最後に斜め
for i in range(3):
    if not A[i][i] in B:
        break
    if i == 2:
        bingo = True

for i in range(3):
    if not A[2-i][i] in B:
        break
    if i == 2:
        bingo = True

if bingo:
    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())

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

punch = []
for b in B:
    for row in range(3):
        if b in A[row]:
            punch.append((row, A[row].index(b)))

for i in range(3):
    for j in range(3):
        if (i, j) in punch:
            if ((i+1)%3, (j+1)%3) in punch and ((i-1)%3, (j-1)%3) in punch:
                print('Yes')
                exit()
            if ((i)%3, (j+1)%3) in punch and ((i)%3, (j-1)%3) in punch:
                print('Yes')
                exit()
            if ((i+1)%3, (j)%3) in punch and ((i-1)%3, (j)%3) in punch:
                print('Yes')
                exit()
print('No')

Submission status: Wrong Answer

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

ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    col = 0
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
      	col += bingo[j][k]
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
  if col == -3:
    ans = "Yes"

if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"

print(ans)

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())
  if b in a1:
    for j in range(3):
      if a1[j] == b:
        a1[j] = 0
        break
  elif b in a2:
    for j in range(3):
      if a2[j] == b:
        a2[j] = 0
        break
  elif b in a3:
    for j in range(3):
      if a3[j] == b:
        a3[j] = 0
        break

        
a1[len(a1):len(a1)] = a2
a1[len(a1):len(a1)] = a3
b = 0
if a1[0:3] == 0 or a1[3:6] == 0 or a1[6:9] == 0:
  b+=1
elif a1[0] == 0 and a1[3] == 0 and a1[6] == 0:
  b += 1
elif a1[1] == 0 and a1[4] == 0 and a1[7] == 0:
  b += 1
elif a1[2] == 0 and a1[5] == 0 and a1[8] == 0:
  b += 1
elif a1[0] == 0 and a1[4] == 0 and a1[8] == 0:
  b += 1
elif a1[2] == 0 and a1[4] == 0 and a1[6] == 0:
  b += 1
  
if b == 1:
  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())
n = int(input())
l = [int(input()) for i in range(n)]
t1 = (a11, a12, a13)
t2 = (a12, a22, a23)
t3 = (a31, a32, a33)
t4 = (a11, a21, a31)
t5 = (a12, a22, a32)
t6 = (a13, a23, a33)
t7 = (a11, a22, a33)
t8 = (a13, a22, a31)
ls = [t1, t2, t3, t4, t5, t6, t7, t8]
for i in ls:
    if i in l :
        print('Yes')
        break
    else :
        print('No')
        break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = []
for i in range(3):
  tmp = input()
  a.append(list(map(int, tmp.split())))

n = int(input())
b = []
for j in range(n):
    b.append(int(input()))


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

def check(a):
    #　たてビンゴ
    for i in range(3):
        if (a[i][0] == 0 & a[i][1] == 0 & a[i][2] == 0):
            print('Yes')
            exit()
        if a[i] == [0, 0, 0]:
            print('Yes')
            exit()
    if a[0][0] == 0 & a[1][1] == 0 & a[2][2] == 0:
            print('Yes')
            exit()
    if a[0][2] == 0 & a[1][1] == 0 & a[2][0] == 0:
            print('Yes')
            exit()
    print('No')

check(a)

Submission status: Wrong Answer

Solution code:
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
A = [a_1,a_2,a_3]
c = []
c_1 = []
for i in range(3):
    for j in range(3):
        for k in b:
            if A[i][j] == k:
                c.append(i)
                c_1.append(j)
d_0 = c.count(0)
d_1 = c.count(1)
d_2 = c.count(2)
D = [d_0,d_1,d_2]
d_3 = c_1.count(0)
d_4 = c_1.count(1)
d_5 = c_1.count(2)
D_2 = [d_3,d_4,d_5]
if (str(0) not in str(D) and str(0) not in str(D_2)):
    print("Yes")
elif (str(3) in str(D) or str(3) in str(D_2)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

  N_list = []
  N = int(input())
  for i in range(N):
    N_list.append(int(input()))
  
  for i in N_list:
    for j in range(3):
      for k in range(3):
        if A[j][k] == i:
          A[j][k] = 0
        else:
          pass
        
  for i in range(3):
    if sum(A[i]) == 0:
      print('Yes')
      exit()
    else:
      pass

  for i in range(3):
    col = 0
    for j in range(3):
      col += A[i][j]
    if col == 0:
      print('Yes')
      exit()
    else:
      pass

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

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

  print('No')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
input1 = list(map(int, (input().split())))
input2 = list(map(int, (input().split())))
input3 = list(map(int, (input().split())))

a = input1 + input2 + input3

n = int(input())

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

for s in b:
    for i in range(9):
        if a[i] == s:
            a[i] = 0

for i in range(3):
    if(a[i] + a[i+3] + a[i+6] == 0):
        print("Yes")
        exit(0)

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

if(a[0] + a[4] + a[8] == 0):
    print("Yes")
    exit(0)

if(a[2] + a[4] + a[6] == 0):
    print("Yes")
    exit(0)

print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

a_list = list(map(int, input().split()))
a_list_2 = list(map(int, input().split()))
a_list_3 = list(map(int, input().split()))

a_total_list = np.array([a_list, a_list_2, a_list_3])
bingo_array = np.zeros((3, 3))

N = int(input())

b_list = []

for i in range(N):
    b = int(input())
    if b in a_total_list:
        bingo_array[np.where(a_total_list == b)[0][0]][np.where(a_total_list == b)[1][0]] = 1

bingo_x_y = 0
break_flag = False
for i in range(3):
    bingo_x = 0
    bingo_y = 0
    if break_flag is True:
        break
    for j in range(3):
        if bingo_array[i][j] == 1:
            bingo_x += 1
        if bingo_x == 3:
            break_flag = True
            break
        if i == 0:
            if bingo_array[j][i] == 1:
                bingo_y += 1
            if bingo_y == 3:
                break_flag = True
                break
        if i == j:
            if bingo_array[i][j] == 1:
                bingo_x_y += 1
            if bingo_x_y == 3:
                break_flag = True
                break

if bingo_x == 3:
    print("Yes")
elif bingo_y == 3:
    print("Yes")
elif bingo_x_y == 3:
    print("Yes")
elif bingo_array[0][2] == 1 and bingo_array[1][1] == 1 and bingo_array[2][0] == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = list()
for x in range(3):
    A.append(input().split())

N = int(input())
b = list()
for x in range(N):
    b.append(input())
result = list()
for x in range(3):
    for y in range(3):
        if A[x][y] in b:
            result.append(x+y)
if 0 in result and 1 in result and 2 in result:
    print('Yes')
elif 3 in result and 4 in result and 5 in result:
    print('Yes')
elif 6 in result and 7 in result and 8 in result:
    print('Yes')
elif 0 in result and 3 in result and 6 in result:
    print('Yes')
elif 1 in result and 4 in result and 7 in result:
    print('Yes')
elif 2 in result and 5 in result and 8 in result:
    print('Yes')
elif 0 in result and 4 in result and 8 in result:
    print('Yes')
elif 2 in result and 4 in result and 6 in result:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main(a: list, n: int, b: list):
    res = [[False, False, False], [False, False, False], [False, False, False]]
    for b in b:
        for i, a_row in enumerate(a):
            for j, a_col in enumerate(a_row):
                if b == a_col:
                    res[i][j] = True

    for i in range(3):
        # row
        if False not in res[i]:
            print("Yes")
            return

        # col
        if False not in [res[0][i], res[1][i], res[2][i]]:
            print("Yes")
            return

    # cross
    # ->
    if False not in [res[0][0], res[1][1], res[2][2]]:
        print("Yes c")
        return

    # <-
    if False not in [res[0][2], res[1][1], res[2][0]]:
        print("Yes c")
        return

    print("No")


if __name__ == "__main__":
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]

    main(a, n, b)

Submission status: Wrong Answer

Solution code:
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
A = [a_1,a_2,a_3]
c = []
c_1 = []
for i in range(3):
    for j in range(3):
        for k in b:
            if A[i][j] == k:
                c.append(i)
                c_1.append(j)
d_0 = c.count(0)
d_1 = c.count(1)
d_2 = c.count(2)
D = [d_0,d_1,d_2]
d_3 = c_1.count(0)
d_4 = c_1.count(1)
d_5 = c_1.count(2)
D_2 = [d_3,d_4,d_5]
print(D)
print(D_2)
if (str(0) not in str(D) and str(0) not in str(D_2)):
    print("Yes")
elif (str(3) in str(D) or str(3) in str(D_2)):
    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()))
d = [a[0], b[0], c[0]]
e = [a[1], b[1], c[1]]
f = [a[2], b[2], c[2]]
g = [a[0], b[1], c[2]]

n = int(input())

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

for l in [a, b, c, d, e, f, g]:
    if (l[0] in bs) and (l[1] in bs) and (l[2] in bs):
        print("Yes")
        break

else:
    print("No")

Submission status: Wrong Answer

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

N = int(input())
b = []

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

match = ''

for star in b:
  for i, item in enumerate(A):
    if item == star:
      match += str(i)

match = sorted(match)
match = ''.join(match)

if '012' in match:
  print('Yes')
elif '345' in match:
  print('Yes')
elif '678' in match:
  print('Yes')
elif '0' in match:
  if '3' in match:
    if '6' in match:
      print('Yes')
  if '4' in match:
    if '8' in match:
      print('Yes')
elif '2' in match:
  if '4' in match:
    if '6' in match:
      print('Yes')
  if '5' in match:
    if '8' in match:
      print('Yes')
elif '1' in match:
  if '4' in match:
    if '7' in match:
      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())
c=0
for i in range(N):
  b=int(input())
  for j in range(3):
    c=0
    for z in range(3):
      if a[j][z]-b==0:
        c+=1
        a[j][z]=0
        if c==3:
          print('Yes')
          sys.exit()
if a[0][0]+a[1][1]+a[2][2]==0 or a[2][0]+a[1][1]+a[0][2]==0 or a[0][0]+a[0][1]+a[0][2]==0 or a[1][0]+a[1][1]+a[1][2]==0 or a[2][0]+a[2][1]+a[2][2]==0:
    print('Yes')
    sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
n1 = list(map(int, input().split()))
n2 = list(map(int, input().split()))
n3 = list(map(int, input().split()))
arr = []
z=0
for i in range(6):
    arr.append(int(input()))
    if arr[i] == n1[0] or arr[i] == n1[1] or arr[i] == n1[2] or arr[i] == n2[0] or arr[i] == n2[1] or arr[i] == n2[2] or arr[i] == n3[0] or arr[i] == n3[1] or arr[i] == n3[2]:
        z+=1
if z >= 3: print("Yes")
else: print("No")

Submission status: Wrong Answer

Solution code:

a1, a2, a3 = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]

var1 = []
var2 = []
var3 = []

for bb in b:
    if bb in a1:
        var1.append(a1.index(bb))

    elif bb in a2:
        var2.append(a2.index(bb))
    elif bb in a3:
        var3.append(a3.index(bb))

#たて
if var1 == var2 == var3:
    print("Yes")

#よこ
elif 0 and 1 and 2 in var1 or  0 and 1 and 2 in var2 or  0 and 1 and 2 in var3 :
    print("Yes")

#ななめ
elif 0 in var1 and 1 in var2 and 2 in var3 or 2 in var1 and 1 in var2 and 0 in var3:
    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=list(set([int(input()) for _ in range(n)]))
l=[]
for i in range(len(b)):
  for j in range(3):
    for k in range(3):
      if b[i]==a[j][k]:
        l.append([j+1,k+1])
if len(l)>=7:
  print('Yes')
elif len(l)<=2:
  print('No')
else:
  if l.count([1,1])==l.count([2,2])==l.count([3,3])==1 or l.count([1,3])==l.count([2,2])==l.count([3,1])==1:
    print('Yes')
  else:
    count1,count2=1,1
    l=sorted(l, key=lambda x: (x[0],x[1]))
    for i in range(len(l)-1):
      if l[i][0]==l[i+1][0]:
        count1+=1
      elif count1!=3:
        count1=1
      if l[i][1]==l[i+1][1]:
        count2+=1
      elif count2!=3:
        count2=1
    if count1==3 or count2==3:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

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

cnt = 0
for ni in nn:
  if ni in a:
    cnt += 1
    a[a.index(ni)] = 0

judge = "No"
for i in range(3):
  if sum(a[i::3])==0 or sum(a[i*3:i*3+3])==0:
    judge = "Yes"
    
if sum(a[::4])==0 or sum(a[2:-2:4])==0:
  judge = "Yes"
  
print(judge)

Submission status: Wrong Answer

Solution code:
yoko_1 = [int(i) for i in input().split()]
yoko_2 = [int(i) for i in input().split()]
yoko_3 = [int(i) for i in input().split()]
tate_1 = [yoko_1[0], yoko_2[0], yoko_3[0]]
tate_2 = [yoko_1[1], yoko_2[1], yoko_3[1]]
tate_3 = [yoko_1[2], yoko_2[2], yoko_3[2]]
naname_1 = [yoko_1[0], yoko_2[1], yoko_3[2]]
naname_2 = [yoko_1[2], yoko_2[1], yoko_3[0]]

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

def bingo(card, call):
    cnt = 0
    for i in card:
        for j in call:
            if i == j:
                cnt += 1
                break
    if cnt == 3:
        return 1
    else:
        return 0

if bingo(yoko_1, bs) + \
bingo(yoko_2, bs) + \
bingo(yoko_3, bs) + \
bingo(tate_1, bs) + \
bingo(tate_2, bs) + \
bingo(tate_3, bs) + \
bingo(naname_2, bs) + \
bingo(naname_2, bs) > 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
ans="No"
A=3
t=[0]*A
x=[0]*A
y=[0]*A
for i in range(A):
    t[i], x[i], y[i] = map(int, input().split())
#print(x[1])

N=int(input())
S=[]
for _ in range(N):
  S.append(input())
#print(S[0])
S1=[int(s) for  s in S]
for i in range(A):
  if t[i] in S1:
    t[i]=0
  if x[i] in S1:
    x[i]=0
  if y[i] in S1:
    y[i]=0
#print(t[0])
if t.count(0)==3:
  ans="Yes"
if x.count(0)==3:
  ans="Yes"
if y.count(0)==3:
  ans="Yes"
if t[0]==0 and x[1]==0 and y[2]==0:
  ans="Yes"
if t[2]==0 and x[1]==0 and y[0]==0:
  ans="Yes"
print(ans)

Submission status: Wrong Answer

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

cnt = 0
for ni in nn:
  if ni in a:
    cnt += 1
    a[a.index(ni)] = 0

judge = "No"
for i in range(3):
  if sum(a[i::3])==0 or sum(a[i*3:i*3+3])==0:
    judge = "Yes"
    
if sum(a[::4])==0 or sum(a[2:-1:4])==0:
  judge = "Yes"
  
print(judge)

Submission status: Wrong Answer

Solution code:
card = list()
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
card.append(a1)
card.append(a2)
card.append(a3)

res = list()
res1 = list(False for i in range(3)) 
res2 = list(False for i in range(3)) 
res3 = list(False for i in range(3)) 
res.append(res1)
res.append(res2)
res.append(res3)
res

for _ in range(n):
    num = int(input())
    for i in range(len(card)):
        for j in range(len(card)):
            if num == card[i][j]:
                res[i][j] = True

final = "No"
tmp = []
for r in range(len(res)):
    tmp.append(all(res[r]))
    if all(tmp) == True:
        final = "Yes"

tmp = []
for r in range(len(res)):
    for c in range(len(res)):         
        tmp.append(res[r][c])
        if all(tmp) == True:
                final = "Yes"

tmp = []
for i in range(len(res)):
    tmp.append(res[i][i])
    if all(tmp) == True:
        final = "Yes"

tmp = []
for i in range(len(res)):
    i = len(res) - i -1
    tmp.append(res[i][i])
    if all(tmp) == True:
        final = "Yes"

print(final)

Submission status: Wrong Answer

Solution code:
arr = []
ans = []
for i in range(3):
  arr.extend(list(map(int,input().split())))
N = int(input())
for j in range(N):
  num = int(input())
  if num in arr:
    ans.append(arr.index(num))
    print(ans)
ans = set(ans)
if (set([0,1,2])<=ans)or(set([3,4,5])<=ans)or(set([6,7,8])<=ans)or(set([0,3,6])<=ans)or(set([1,4,7])<=ans)or(set([2,5,8])<=ans)or(set([0,4,8])<=ans)or(set([2,4,6])<=ans):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import itertools
import sys

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for i in range(N):
  n = int(input())
  num_list.append(n)
set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i},{c,e,g}]
the_set = set(num_list) & set([a,b,c,d,e,f,g,h,i])
v = itertools.permutations(the_set,3)
for i in v:
  if i in set_list:
    print('Yes')
    sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
a,b,c =map(int,input().split())
d,e,f =map(int,input().split())
g,h,i =map(int,input().split())
N=input()
N= int(N)
z = [ input() for i in range(N)]
z =map(int,z)
if a and d and g in z or b and e and h in z or c and f and i in z or a and b and c in z or c and e and f in z or g and h and i in z or a and e and i in z or g and e and c in z or d and e and f in z:
  print('Yes')
else :
  print('No')

Submission status: Wrong Answer

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N =int(input())
B = []
for _ in range(N):
    B.append(input())

a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

Solution code:
input1 = list(map(int, (input().split())))
input2 = list(map(int, (input().split())))
input3 = list(map(int, (input().split())))

a = input1 + input2 + input3

n = int(input())

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

for s in b:
    for i in range(9):
        if a[i] == s:
            a[i] = 0

for i in range(3):
    if(a[i] + a[i+3] + a[i+6] == 0):
        print("YES")
        exit(0)

for i in range(0, 3, 3):
    if(a[i] + a[i+1] + a[i+2] == 0):
        print("YES")
        exit(0)

if(a[0] + a[4] + a[8] == 0):
    print("YES")
    exit(0)

if(a[2] + a[4] + a[6] == 0):
    print("YES")
    exit(0)

print("NO")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = []
FLAGS = True
for i in range(3):
  N1 = list(map(int, input().split(' ')))
  N.append(N1)

N = np.array(N)

M = int(input())

for i in range(M):
  a = int(input())
  
  for j in range(3):
    for k in range(3):
      if N[j, k] == a:
        N[j, k] = 0
  if (np.all(N == 0, axis = 0).any(0)) or (np.all(N == 0, axis = 1).any(0)) or (np.all(np.diag(N) == 0).any(0)) or (np.all(np.diag(N) == 0).any(0)):
  #if (N[0, :].all() == 0) or (N[1, :].all() == 0) or  (N[2, :].all() == 0) or  (N[:, 0].all() == 0) or (N[:, 1].all() == 0) or (N[:, 2].all() == 0) or (np.diag(N).all() == 0) or (np.diag(np.transpose(N)).all() == 0):
    print('Yes')
    FLAGS = True
    break
  else:
    FLAGS = False
    continue
      
if FLAGS == False:     
  print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
a = list(np.array(a).flatten())
N = int(input())
index = []
for _ in range(N):
    b_i = int(input())
    if b_i in a:
        indexes = [i for i, x in enumerate(a) if x == b_i]
        for i in indexes:
            index.append(i)
# print(index)
for i in sorted(index):
    if i + 1 in index and i + 2 in index:
        print("Yes")
        exit()
    if i + 2 in index and i + 4 in index:
        print("Yes")
        exit()
    if i + 3 in index and i + 6 in index:
        print("Yes")
        exit()
    if i + 4 in index and i + 8 in index:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
import itertools

a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
a = list(itertools.chain.from_iterable(a))

def return_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

for i in b:
    if return_index(a, i) >= 0:
        a[return_index(a, i)] = 0

def check_bingo(a):
    if a[0] + a[1] + a[2] == 0:
        return True
    if a[3] + a[4] + a[5] == 0:
        return True
    if a[6] + a[7] + a[8] == 0:
        return True
    if a[0] + a[3] + a[6] == 0:
        return True
    if a[1] + a[4] + a[7] == 0:
        return True
    if a[2] + a[5] + a[8] == 0:
        return True
    if a[0] + a[4] + a[8] == 0:
        return True
    if a[2] + a[4] + a[6] == 0:
        return True
    return False

print("Yes") if check_bingo(a) else print("No")

Submission status: Wrong Answer

Solution code:
ans="No"
A=3
t=[0]*A
x=[0]*A
y=[0]*A
for i in range(A):
    t[i], x[i], y[i] = map(int, input().split())
#print(x[1])

N=int(input())
S=[]
for _ in range(N):
  S.append(input())
#print(S[0])
S1=[int(s) for  s in S]
for i in range(A):
  if t[i] in S1:
    t[i]=0
  if x[i] in S1:
    x[i]=0
  if y[i] in S1:
    y[i]=0
print(t[0])
if t.count(0)==3:
  ans="Yes"
if x.count(0)==3:
  ans="Yes"
if y.count(0)==3:
  ans="Yes"
if t[0]==0 and x[1]==0 and y[2]==0:
  ans="Yes"
if t[2]==0 and x[1]==0 and y[0]==0:
  ans="Yes"
print(ans)

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)]
l=[]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i]==a[j][k]:
        l.append([j+1,k+1])
if len(l)>=7:
  print('Yes')
elif len(l)<=2:
  print('No')
else:
  if l.count([1,1])==l.count([2,2])==l.count([3,3])==1 or l.count([1,3])==l.count([2,2])==l.count([3,1])==1:
    print('Yes')
  else:
    count1,count2=1,1
    l=sorted(l, key=lambda x: (x[0],x[1]))
    for i in range(len(l)-1):
      if l[i][0]==l[i+1][0]:
        count1+=1
      elif count1!=3:
        count1=1
      if l[i][1]==l[i+1][1]:
        count2+=1
      elif count2!=3:
        count2=1
    if count1==3 or count2==3:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
b = [0] * 10
while True:
    flag = 0
    try:
        n = int(input())
        if n in a:
            k = a.index(n)
            b[k] = 1
            if b[4] == 1 and b[8 - k] == 1 and k != 4:
                print('Yes')
                flag = 1
                break
    except:
        print('No')
        break

Submission status: Wrong Answer

Solution code:
up = list(input().split())
mid = list(input().split())
down = list(input().split())

table = [up, mid, down]
# print(table)
nums = []
while True:
    try:
        nums.append(input())
    except EOFError:
        break
# print(nums)

for i in range(3):
  for j in range(3):
    if table[i][j] in nums:
      table[i][j] = 'T'

flag = False
# yoko check
for i in range(3):
  if table[i].count('T') == 3:
    print('Yes')
    flag = True
    if flag == True:
      break

# tate check
if flag == False:
  if table[0][0]=='T' and table[0][1]=='T' and table[0][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[1][0]=='T' and table[1][1]=='T' and table[1][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[2][0]=='T' and table[2][1]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True

# naname check
if flag == False:
  if table[0][0]=='T' and table[1][1]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][2]=='T' and table[1][1]=='T' and table[2][0]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A_list = []

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

N = int(input())
narray = np.zeros((3, 3), dtype=np.int)


for j in range(N):
    b = int(input())

    for n in range(3):
        for m in range(3): 
            if A_list[n][m] == b:
                narray[n, m] = 1


n_list = np.count_nonzero(narray == 1, axis = 0)
m_list = np.count_nonzero(narray == 1, axis = 1)
print(n_list)
print(m_list)

print(narray)

if np.any(n_list == 3) or np.any(m_list == 3):
    print('Yes')
    exit()

if narray[0, 0] == 1 and narray[1, 1] == 1 and narray[2, 2] == 1:
    print('Yes')
    exit()

if narray[0, 2] == 1 and narray[1, 1] == 1 and narray[2, 0] == 1:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[input() for i in range(N)]
if b.count(l[0][0])>0 and b.count(l[0][1])>0 and b.count(l[0][2])>0:
    print("Yes")
    exit()
if b.count(l[1][0])>0 and b.count(l[1][1])>0 and b.count(l[1][2])>0:
    print("Yes")
    exit()
if b.count(l[2][0])>0 and b.count(l[2][1])>0 and b.count(l[2][2])>0:
    print("Yes")
    exit()
if b.count(l[0][0])>0 and b.count(l[1][0])>0 and b.count(l[2][0])>0:
    print("Yes")
    exit()
if b.count(l[0][1])>0 and b.count(l[1][1])>0 and b.count(l[2][1])>0:
    print("Yes")
    exit()
if b.count(l[0][2])>0 and b.count(l[1][2])>0 and b.count(l[2][2])>0:
    print("Yes")
    exit()
if b.count(l[0][0])>0 and b.count(l[1][1])>0 and b.count(l[2][2])>0:
    print("Yes")
    exit()
if b.count(l[0][2])>0 and b.count(l[1][1])>0 and b.count(l[2][0])>0:
    print("Yes")
    exit()
else:
    print("No")