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:
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"
for r in range(len(res)):
    tmp = []
    tmp.append(all(res[r]))
    if all(tmp) == True:
        final = "Yes"

for r in range(len(res)):
    tmp = []
    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)):
    j = len(res) - i - 1
    tmp.append(res[i][j])
if all(tmp) == True:
    final = "Yes"

print(final)

Submission status: Wrong Answer

Solution code:
import itertools
# ここを参考にした
# https://note.nkmk.me/python-list-index/

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
Bingo_index=[]
master =[]
# 二次元リスト
Row = 3
List=[[int(j) for j in input().split()] for i in range(Row)]
# 一次元リスト
dim_List=list(itertools.chain.from_iterable(List))
# print(dim_List)

n = int(input())
# print(n)
Num=[int(input()) for i in range(n)]
# print(Num)
# print(set(dim_List) & set(Num))
# 入力処理ここまで

Common = list(set(dim_List) & set(Num))
# print(Common)
# https://teratail.com/questions/156336
# リストに要素をコピーする方法↑
for a in Common:
    # if(my_index(dim_List,a) == False):
    #     print('No')
    Bingo_index.append(dim_List.index(a))
#
# print('Bingo_indexは')
# print(Bingo_index)
# print(sorted(Bingo_index))
if len(Bingo_index) == 0:
     print('No')
     exit()
    # Bingo_indexにビンゴしてるdim_Listの要素のインデックスが入ってる
answer1 = len(list(set([0, 1, 2])&set(Bingo_index)))
answer2 = len(list(set([3, 4, 5])&set(Bingo_index)))
answer3 = len(list(set([6, 7, 8])&set(Bingo_index)))
answer4 = len(list(set([0, 4, 8])&set(Bingo_index)))
answer5 = len(list(set([0, 3, 6])&set(Bingo_index)))
answer6 = len(list(set([1, 4, 7])&set(Bingo_index)))
answer7 = len(list(set([2, 5, 8])&set(Bingo_index)))

# Bingo_indexの中身にとanswer1~7の組み合わせがあるかどうか調べる
# 全部のアンサーとandをとってどれかの長さが3の奴があればyes出力や
master.append(answer1)
master.append(answer2)
master.append(answer3)
master.append(answer4)
master.append(answer5)
master.append(answer6)
master.append(answer7)
# print(master)
if master.count("3") >= 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
b=len(a)
c=[a]
w=0
for i in range(b-1):
    c.append(list(map(int,input().split())))
N=int(input())
d=[]
o=0
for y in range(N):
    d.append(int(input()))
for n in d:
    for p in range(b):
        for j in range(b):
            if c[p][j]==n:
               c[p][j]=0
                
for t in c:
    for h in t:
        if c.count(0)==b:
            o=1
            break
    else:
        continue
    break
for v in range(b):
    w=0
    for k in c:
        if k[v]==0:
            w+=1
        if w==b:
            o=1
w=0
for ji in range(b):
    if c[ji][ji]==0:
        w+=1
    if w==b:
        o=1
w=0
for ji2 in range(b):
    g=b-ji2-1
    if c[ji2][g]==0:
        w+=1
    if w==b:
        o=1
for v1 in range(b):
    w=0
    for k in range(b):
        if c[k][v1]==0:
            w+=1
        if w==b:
            o=1
if o==1:
    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)]
mas = [[0]*3]*3
ans = []
for m in range(n):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b[m]:
                ans.append([i,j])
for i,j in ans:
    bingo[i][j] = -1
lists = []
cnt = 0

if i == 0 and j == 0:
    if bingo[i][j] == -1 and bingo[i][j+1] == -1 and bingo[i][j+2] == -1:
                cnt -1
    if bingo[i][j] == -1 and bingo[i+1][j] == -1 and bingo[i+2][j] == -1:
                cnt = 1
if i == 0 and j == 0:
        if bingo[i][j] == -1 and bingo[i+1][j+1] == -1 and bingo[i+2][j+2] == -1:
                cnt = 1
if i == 0 and j == 2:
            if bingo[i][j] == -1 and bingo[i+1][j-1] == -1 and bingo[i+2][j-2] == -1:
                cnt = 1
if cnt == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# c = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
import sys
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
v = 0

for i in range(0, n):
    v = int(input())
    if v in a1:
        a1[a1.index(v)] = 0
    if v in a2:
        a2[a2.index(v)] = 0
    if v in a3:
        a3[a3.index(v)] = 0


if sum(a1) == 0:
    print('Yes')
    sys.exit()

if sum(a2) == 0:
    print('Yes')
    sys.exit()

if sum(a3) == 0:
    print('Yes')
    sys.exit()

if a1[0] == a2[1] == a3[2] == 0:
    print('Yes')
    sys.exit()

if a3[0] == a2[1] == a1[2] == 0:
    print('Yes')
    sys.exit()
    
print('No')

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

Solution code:
_3DArray = []
numberArray = []
arr = []
input_line = input().split(' ')
numberArray.append(input_line)
input_line = input().split(' ')
numberArray.append(input_line)
input_line = input().split(' ')
numberArray.append(input_line)
_3DArray.append(numberArray)
 
numberArray = []
input_line = []
input_line2 = []
input_line3 = []
for i in _3DArray[0]:
  input_line.append(i[0])
  input_line2.append(i[1])
  input_line3.append(i[2])
numberArray.append(input_line)
numberArray.append(input_line2)
numberArray.append(input_line3)
_3DArray.append(numberArray)
 
numberArray = []
input_line = []
input_line2 = []
k = 0
l = 2
for i in _3DArray[0]:
  input_line.append(i[k])
  input_line2.append(i[l])
numberArray.append(input_line)
numberArray.append(input_line2)
_3DArray.append(numberArray)
 
num = int(input())
if num == 1 or num == 2:
  print('No')
else:
  for i in range(num):
    arr.append(input())
  
  for i in _3DArray:
    for j in i:
      for k in arr:
        if k in j:
          j.remove(k)
 
  flag = False
  for i in _3DArray:
    if len(i) != 3:
      flag = True
 
  if flag:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

bingo = [ list(map(int, input().split())) for _ in range(3) ]
t_or_f = [ [False]*3 for _ in range(3) ]

nums = [ r for i in range(3) for r in bingo ]

n = int(input())
for _ in range(n):
  i = int(input())

  if i in nums:
    for x in range(3):
      for y in range(3):
        if bingo[x][y] == i:
          t_or_f[x][y] = True
          break


is_bingo = False
if t_or_f[0][0] and t_or_f[1][1] and t_or_f[2][2]:
  is_bingo = True
  print('Yes')
elif t_or_f[0][2] and t_or_f[1][1] and t_or_f[2][0]:
  is_bingo = True
  print('Yes')
else:
  for i in range(3):
    if t_or_f[i][i] and t_or_f[i+1][i+1] and t_or_f[i+2][i+2]:
      is_bingo = True
      print('Yes')
      sys.exit()

if not is_bingo: print('No')

Submission status: Wrong Answer

Solution code:
#配列準備
N = 3
A = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    A.append(array)

#番号準備
N = int(input())
B = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    B.append(array)

#確認
print("yes")

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)):
    y = c.index(0)
    u = c_1.index(0)
    if y != u:
        print("No")
    else:
        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:

# S, T = input().split()
# A, B = map(int, input().split())
# U = input()
# if S == U: A -= 1
# else: B -= 1
# print(A, B)

def main():
    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()))

    A=[]

    A.append(A1)
    A.append(A2)
    A.append(A3)


    #print(A)
    #print(A[1][1])

    flags = [[False,False,False],[False,False,False],[False,False,False]]


    for i in B:
        for j in range(3):

            if A[0][j] == i:
                flags[0][j] = True
            if A[1][j] == i:
                flags[0][j] = True
            if A[2][j] == i:
                flags[0][j] = True
            
            if A[j][0] == i:
                flags[0][j] = True
            if A[j][1] == i:
                flags[0][j] = True
            if A[j][2] == i:
                flags[0][j] = True

#check
            for k in range(3):
                if flags[k][0] == True and flags[k][1] == True and flags[k][2] == True:
                    print("Yes")
                    return
                if flags[0][k] == True and flags[0][k] == True and flags[0][k] == True:
                    print("Yes")
                    return

            if flags[0][0] == True and flags[1][1] == True and flags[2][2] == True : 
                print("Yes")
                return
            if flags[0][2] == True and flags[1][1] == True and flags[2][0] == True :
                print("Yes")
                return

    print("No")

main()

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"
for r in range(len(res)):
    tmp = []
    tmp.append(all(res[r]))
    if all(tmp) == True:
        final = "Yes"

for r in range(len(res)):
    tmp = []
    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:
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [list(map(int,input().split())) for i in range(N)]


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

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

Submission status: Wrong Answer

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

    for j in range(3):
        for k in range(3):
            if l[j][k] == m:
                l[j][k] = -1
o=0
p=0
for j in range(3):
    for k in range(3):
        o+=l[j][k]
        p+=l[k][j]
    if o==-3 or p==-3:
        print('Yes')
        exit()
    o=0
    p=0
if l[0][0]+l[1][1]+l[2][2]==-3 or l[0][2]+l[1][1]+l[2][0]==-3:
    print('Yes2')
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()))


count = int(input())

for num in range(count):
    x = int(input())
    for y in range(3):
        if a[y] == x:
            a[y] = 0
    for y in range(3):
        if b[y] == x:
            b[y] = 0
    for y in range(3):
        if c[y] == x:
            c[y] = 0

ans = 0
ans = a[0] * a[1] * a[2]
ans += b[0] * b[1] * b[2]
ans += c[0] * c[1] * c[2]
ans += a[0] * b[0] * c[0]
ans += a[1] * b[1] * c[1]
ans += a[2] * b[2] * c[2]

if ans == 0:
    print("Yes")
elif a[0]+a[1]+a[2] == 0:
    print("Yes")
elif b[0]+b[1]+b[2] == 0:
    print("Yes")
elif c[0]+c[1]+c[2] == 0:
    print("Yes")
elif a[0] + b[0] + c[0] ==0:
    print("Yes")
elif a[1] + b[1] + c[1] ==0:
    print("Yes")
elif a[2] + b[2] + c[2] ==0:
    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:
a11, a12, a13 = input().split()
a21, a22, a23 = input().split()
a31, a32, a33 = input().split()
n = int(input())
l = [int(input()) for i in range(n)]

if all(a11 and a12 and a13) in l:
    print('Yes')
elif all(a12 and a22 and a23) in l:
    print('Yes')
elif all(a31 and a32 and a33) in l:
    print('Yes')
elif all(a11 and a21 and a31) in l:
    print('Yes')
elif all(a12 and a22 and a32) in l:
    print('Yes')
elif all(a13 and a23 and a33) in l:
    print('Yes')
elif all(a11 and a22 and a33) in l:
    print('Yes')
elif all(a13 and a22 and a31) in l:
    print('Yes')
else :
    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:
#配列準備
N = 3
A = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    A.append(array)
print(type(A))

#番号準備
N = int(input())
B = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    B.append(array)

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:
import itertools
# ここを参考にした
# https://note.nkmk.me/python-list-index/

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
Bingo_index=[]
master =[]
# 二次元リスト
Row = 3
List=[[int(j) for j in input().split()] for i in range(Row)]
# 一次元リスト
dim_List=list(itertools.chain.from_iterable(List))
# print(dim_List)

n = int(input())
# print(n)
Num=[int(input()) for i in range(n)]
# print(Num)
# print(set(dim_List) & set(Num))
# 入力処理ここまで

Common = list(set(dim_List) & set(Num))
# print(Common)
# https://teratail.com/questions/156336
# リストに要素をコピーする方法↑
for a in Common:
    # if(my_index(dim_List,a) == False):
    #     print('No')
    Bingo_index.append(dim_List.index(a))
#
# print('Bingo_indexは')
# print(Bingo_index)
# print(sorted(Bingo_index))
if len(Bingo_index) == 0:
     print('No')
     exit()
    # Bingo_indexにビンゴしてるdim_Listの要素のインデックスが入ってる
answer1 = len(list(set([0, 1, 2])&set(Bingo_index)))
answer2 = len(list(set([3, 4, 5])&set(Bingo_index)))
answer3 = len(list(set([6, 7, 8])&set(Bingo_index)))
answer4 = len(list(set([0, 4, 8])&set(Bingo_index)))
answer5 = len(list(set([0, 3, 6])&set(Bingo_index)))
answer6 = len(list(set([1, 4, 7])&set(Bingo_index)))
answer7 = len(list(set([2, 5, 8])&set(Bingo_index)))

# Bingo_indexの中身にとanswer1~7の組み合わせがあるかどうか調べる
# 全部のアンサーとandをとってどれかの長さが3の奴があればyes出力や
master.append(answer1)
master.append(answer2)
master.append(answer3)
master.append(answer4)
master.append(answer5)
master.append(answer6)
master.append(answer7)
# print(master)
for i in master:
    if i == 3:
        print('Yes')
        break

Submission status: Wrong Answer

Solution code:
card=[]
ans=[]
for i in range(3):
    a,b,c=map(int,input().split())
    card.append(a)
    card.append(b)
    card.append(c)
n=int(input())
for i in range(n):
    b=int(input())
    if b in card and b%3==0:
        ans.append(0)
    elif b in card and b%3==1:
        ans.append(1)
    elif b in card and b%3==2:
        ans.append(2)
    else:
        ans.append(3)
if ans.count(0)==3 or ans.count(1)==3 or ans.count(2)==3:
    print("Yes")
elif ans.count(0)>=1 and ans.count(1)>=1 and ans.count(2)>=1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
ans = 0
for i in range(3):
  for j in range(3):
    for k in B:
      if A[i][j] == k:
        A[i][j] = 1
for i in range(3):
  if A[i].count(1) == 3:
    ans += 1
  elif A[0][i] == 1 and A[2][i] == 1 and A[2][i] == 1:
    ans += 1
  elif A[0][0] == 1 and A[1][1] == 1 and A[2][2] == 1:
    ans += 1
  elif A[0][2] == 1 and A[1][1] == 1 and A[2][0] == 1:
    ans += 1
if ans > 1:
  print("Yes")
else:
  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 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")
    exit()
elif bingo_y == 3:
    print("Yes")
    exit()
elif bingo_x_y == 3:
    print("Yes")
    exit()
elif bingo_array[0][2] == 1 and bingo_array[1][1] == 1 and bingo_array[2][0] == 1:
    print("Yes")
    exit()
else:
    print("No")
    exit()

Submission status: Wrong Answer

Solution code:
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
N = int(input())
d_list = [int(input()) for k in range(N)]


for n in range(3):
    for p in range(3):
        if d_list[n] == a_list[p]:
            a_list[p] = 555
    for q in range(3):
        if d_list[n] == b_list[q]:
            b_list[q] = 555
    for r in range(3):
        if d_list[n] == c_list[r]:
            c_list[r] = 555

if a_list[0] == a_list[1] == a_list[2] == 555:
    print('Yes')

elif b_list[0] == b_list[1] == b_list[2] == 555:
    print('Yes')

elif c_list[0] == c_list[1] == c_list[2] == 555:
    print('Yes')

elif a_list[0] == b_list[0] == c_list[0] == 555:
        print('Yes')
elif a_list[1] == b_list[1] == c_list[1] == 555:
        print('Yes')
elif a_list[2] == b_list[2] == c_list[2] == 555:
    print('Yes')
elif a_list[0] == b_list[1] == c_list[2] == 555:
    print('Yes')

elif a_list[2] == b_list[1] == c_list[0] == 555:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
_3DArray = []
numberArray = []
arr = []
input_line = input().split(' ')
numberArray.append(input_line)
input_line = input().split(' ')
numberArray.append(input_line)
input_line = input().split(' ')
numberArray.append(input_line)
_3DArray.append(numberArray)

numberArray = []
input_line = []
input_line2 = []
input_line3 = []
for i in _3DArray[0]:
  input_line.append(i[0])
  input_line2.append(i[1])
  input_line3.append(i[2])
numberArray.append(input_line)
numberArray.append(input_line2)
numberArray.append(input_line3)
_3DArray.append(numberArray)

numberArray = []
input_line = []
input_line2 = []
k = 0
l = 2
for i in _3DArray[0]:
  input_line.append(i[k])
  input_line2.append(i[l])
numberArray.append(input_line)
numberArray.append(input_line2)
_3DArray.append(numberArray)

num = int(input())
for i in range(num):
  arr.append(input())
  
for i in _3DArray:
  for j in i:
    for k in arr:
      if k in j:
        j.remove(k)

flag = False
for i in _3DArray:
  if len(i) != 3:
    flag = True

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

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())
# print('n', n)
b = []
for j in range(n):
    b.append(int(input()))

# print('a', a)
# print('b', b)

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

def check(a):
    #　たてビンゴ
    # 斜め
    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()
    for i in range(3):
        if (a[0][i] == 0 & a[1][i] == 0 & a[2][i] == 0):
            print('Yes')
            exit()
        if a[i] == [0, 0, 0]:
            print('Yes')
            exit()
    print('No')

check(a)

Submission status: Wrong Answer

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N =int(input())
B = []
for _ in range(N):
    B.append(int(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:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(map(int, input().split()))
d=x+y+z
nalist=[]
N=int(input())
for i in range(N):
    na = int(input())
    nalist.append(na)

for i in nalist:
    if i in d:
        counter=d.index(i)
        d[counter]=101

if d[0]and d[1]and d[2]==101:
    print("Yes")
elif d[3]and d[4]and d[5]==101:
    print("Yes")
elif d[6]and d[7]and d[8]==101:
    print("Yes")
elif d[0]and d[3]and d[6]==101:
    print("Yes")
elif d[1]and d[4]and d[7]==101:
    print("Yes")
elif d[2]and d[5]and d[8]==101:
    print("Yes")
elif d[0]and d[4]and d[8]==101:
    print("Yes")
elif d[2]and d[4]and d[6]==101:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

for j in range(N):
    number.append(int(input()))

result = []
for n in range(N):
    for t in range(3):
        for y in range(3):
            if(bingo[t][y] == number[n]):
                result.append([t,y])

bingo_a = 'No'
for r in range(len(result)):
    for t in range(3):
        t_a = 0
        for y in range(3):
            if(result[r][0] == t and result[r][1] == y):
                t_a = t_a + 1
        if(t_a == 3):
            bingo_a = 'Yes'

for r in range(len(result)):
    for y in range(3):
        y_a = 0
        for t in range(3):
            if(result[r][0] == t and result[r][1] == y):
                y_a = y_a + 1
        if(y_a == 3):   
            bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 0):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 2):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 2):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 0):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

print(bingo_a)

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


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


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

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

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


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:
As = [list(map(int, input().split())) for x in range(3)]
N = int(input())
bs = [int(input()) for x in range(N)]


def create_bingo_card():
  result = [[0, 0, 0] for x in range(3)]
  i = 0
  while True:
    i2 = 0
    while True:
      if bs[i2] in As[i]:
        result[i][As[i].index(bs[i2])] += 1
      i2 += 1
      if i2 == len(bs):
        break
    i += 1
    if i == len(As):
      break
  return result


def solvd(bingo):
  tmp = [bingo[0][0], bingo[1][1], bingo[2][2]]
  if check1(tmp):
    print("Yes")
    return

  tmp = [bingo[0][2], bingo[1][1], bingo[2][0]]
  if check1(tmp):
    print("Yes")
    return

  r = 0
  for x in range(2):
    tmp = [bingo[0][x], bingo[1][x], bingo[2][x]]
    if check1(tmp):
      print("Yes")
      return

    bingoSet = set(bingo[x])
    if check2(bingoSet):
      r += 1

  if r >= 1:
    print("Yes")
    return
  print("No")


def check1(s):
  return s.count(1) == 3


def check2(s):
  return not (0 in list(s))


def main():
  Cs = create_bingo_card()
  solvd(Cs)


if __name__ == "__main__":
    main()