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:
import numpy as np
A_mat = np.array([list(map(int, input().split())) for _ in range(3)])
N = int(input())
b_list = [int(input()) for _ in range(N)]
tf_mat = np.zeros_like(A_mat)
for i in range(3):
    for j in range(3):
        a = A_mat[i, j]
        if a in b_list:
            tf_mat[i][j] = 1
ANS = 'No'
if np.all(tf_mat[0][:]) or np.all(tf_mat[1][:]) or np.all(tf_mat[2][:]): ANS = 'Yes'
if np.all(tf_mat[:][0]) or np.all(tf_mat[:][1]) or np.all(tf_mat[:][2]): ANS = 'Yes'
if np.all([tf_mat[0][0], tf_mat[1][1], tf_mat[2][2]]): ANS = 'Yes'
if np.all([tf_mat[0][2], tf_mat[1][1], tf_mat[2][0]]): ANS = 'Yes'
print(ANS)

Submission status: Wrong Answer

Solution code:
A=[]
cnt=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]="○"
for l in range(3):
  if A[l][0]=="○"and A[l][1]=="○"and A[l][2]:
    cnt+=1
  elif A[0][l]=="○" and A[1][l]=="○"and A[2][l]=="○":
    cnt+=1
  elif A[0][0]=="○"and A[1][1]=="○"and A[2][2]=="○":
    cnt+=1
  elif A[0][2]=="○"and A[1][1]=="○"and A[2][0]=="○":
    cnt+=1

 # print(A)
if cnt>=1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A=[]
cnt=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]="○"
for l in range(3):
  if A[l][0]=="○"and A[l][1]=="○"and A[l][2]:
    cnt+=1
  elif A[2-l][l]=="○" and A[2-l][1]=="○"and A[2-l][2]=="○":
    cnt+=1
  elif A[0][0]=="○"and A[1][1]=="○"and A[2][2]=="○":
    cnt+=1
  elif A[0][2]=="○"and A[1][1]=="○"and A[2][0]=="○":
    cnt+=1

 # print(A)
if cnt>=1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a =[]
for i in range(3):
    a.append(input().split())
#print(a)
n = int(input())



for k in range(n):
    b = input()
    for i in range(3):
      for j in range(3):
        if(b in a[i][j]):
          a[i][j] = 'maru'
          #print('OK')
      

frag = False


for i in range(3):
     if((a[i][0] == 'maru') and (a[i][1] == 'maru')and(a[i][2] == 'maru')):
        frag = True

for i in range(3):
     if((a[0][i] == 'maru') and (a[1][i] == 'maru')and(a[2][i] == 'maru')):
        frag = True


"""
for k in range(3):
    i = 0
    #縦
    if((a[i][k] == 'maru') and (a[i+1][k] == 'maru')and(a[i+2][k] == 'maru')):
        frag = True


for k in range(3):
    j = 0
    #横
    if((a[k][j] == 'maru') and (a[k][j+1] == 'maru')and(a[k][j+2] == 'maru')):
        frag = True
"""

#斜め
if((a[0][0] == 'maru')and(a[1][1] == 'maru')and(a[2][2]=='maru')):
    frag = True
if((a[2][0] == 'maru')and(a[1][1] == 'maru')and(a[0][2]=='maru')):
    frag = True
        

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

Submission status: Wrong Answer

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



for k in range(n):
    b = input()
    for i in range(3):
      for j in range(3):
        if(b in a[i][j]):
          a[i][j] = 'maru'
          #print('OK')
      

frag = False


for i in range(3):
     if((a[i][0] == 'maru') and (a[i][1] == 'maru')and(a[i][2] == 'maru')):
        frag = True

for i in range(3):
     if((a[0][i] == 'maru') and (a[1][i] == 'maru')and(a[2][i] == 'maru')):
        frag = True


"""
for k in range(3):
    i = 0
    #縦
    if((a[i][k] == 'maru') and (a[i+1][k] == 'maru')and(a[i+2][k] == 'maru')):
        frag = True


for k in range(3):
    j = 0
    #横
    if((a[k][j] == 'maru') and (a[k][j+1] == 'maru')and(a[k][j+2] == 'maru')):
        frag = True
"""

#斜め
if((a[0][0] == 'maru')and(a[1][1] == 'maru')and(a[2][2]=='maru')):
    frag = True
if((a[2][0] == 'maru')and(a[1][1] == 'maru')and(a[0][2]=='maru')):
    frag = True
        

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

Submission status: Wrong Answer

Solution code:
#input
import numpy as np
A = np.full((3, 3), 0)

A[0, 0], A[0, 1], A[0, 2] = map(int, input().split())
A[1, 0], A[1, 1], A[1, 2] = map(int, input().split())
A[2, 0], A[2, 1], A[2, 2] = map(int, input().split())
N = int(input())
B = [0] * N
for j in range(N):
    B[j] = int(input())

#output
if A[0, 0] in B and A[0, 1] in B and A[0, 2] in B:
    print("Yes")
elif A[1, 0] in B and A[1, 1] in B and A[1, 2] in B:
    print("Yes")
elif A[2, 0] in B and A[2, 1] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 0] in B and A[1, 0] in B and A[2, 0] in B:
    print("Yes")
elif A[0, 1] in B and A[1, 1] in B and A[2, 1] in B:
    print("Yes")
elif A[0, 2] in B and A[1, 2] in B and A[2, 2] in B:
    print("Yes")
elif A[0, 0] in B and A[1, 1] in B and A[2, 2] in B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a1=input().split()
a2=input().split()
a3=input().split()
A=[a1,a2,a3]
b=[int(input()) for i in range(int(input()))]
if a1[0] and a1[1] and a1[2] in b:
    print("Yes")
elif a2[0] and a2[1] and a2[2] in b:
    print("Yes")
elif a3[0] and a3[1] and a3[2] in b:
    print("Yes")
elif a1[0] and a2[0] and a3[0] in b:
    print("Yes")
elif a1[1] and a2[1] and a3[1] in b:
    print("Yes")
elif a1[2] and a2[2] and a3[2] in b:
    print("Yes")
elif a1[0] and a2[1] and a3[2] in b:
    print("Yes")
elif a1[2] and a2[1] and a3[0] in b:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

# A = [input().split() for l in range(3)] 

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

print(type(int(A[0][0])))
print(type(b[0]))

if A[0][0] == b[0]:
    print("Yes")

for i in range(3):
    for j in range(3):
        for k in range(N):
            #print(A[i][j], b[k])
            if A[i][j] == b[k]:
                A[i][j] = 1000

for i in range(3):
    if A[i][0] == A[i][1] and A[i][1] == A[i][2] and A[i][2] == 1000:
        flag = 1
    if A[0][i] == A[1][i] and A[1][i] == A[2][i] and A[2][i] == 1000:
        flag = 1
    if A[0][0] == A[1][1] and A[1][1] == A[2][2] and A[2][2] == 1000:
        flag = 1
    if A[0][2] == A[1][1] and A[1][1] == A[2][0] and A[2][0] == 1000:
        flag = 1

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

Submission status: Wrong Answer

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

# A = [input().split() for l in range(3)] 

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

print(type(int(A[0][0])))
print(type(b[0]))

if A[0][0] == b[0]:
    print("Yes")

for i in range(3):
    for j in range(3):
        for k in range(N):
            #print(A[i][j], b[k])
            if A[i][j] == b[k]:
                A[i][j] = 1000

for i in range(3):
    if A[i][0] == A[i][1] and A[i][1] == A[i][2] and A[i][2] == 1000:
        flag = 1
    if A[0][i] == A[1][i] and A[1][i] == A[2][i] and A[2][i] == 1000:
        flag = 1
    if A[0][0] == A[1][1] and A[1][1] == A[2][2] and A[2][2] == 1000:
        flag = 1
    if A[0][2] == A[1][1] and A[1][1] == A[2][0] and A[2][0] == 1000:
        flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")
print(A)

Submission status: Wrong Answer

Solution code:
A=[]
flag=0
for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  s=int(input())
  for k in range(3):
    if s in A[k]:
      A[k][A[k].index(s)]=0

if A[0]==[0,0,0] or A[1]==[0,0,0] or A[2]==[0,0,0]:
  print("Yes")
  flag=1
elif A[1][1]==0 and A[2][2]==0 and A[0][0]==0:
  print("Yes")
  flag=1
elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
  print("Yes")
  flag=1
else:
  for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
      print("Yes")
      flag=1
      break
if flag == 0:
  print("No")
print(A)

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict

f_row_nums = list(input().split())
s_row_nums = list(input().split())
t_row_nums = list(input().split())
N = int(input())
chosen_nums = [input() for _ in range(N)]

f_dict = OrderedDict()
for key in f_row_nums:
    print(key)
    f_dict[key] = False
s_dict = OrderedDict()
for key in s_row_nums:
    s_dict[key] = False
t_dict = OrderedDict()
for key in t_row_nums:
    t_dict[key] = False

for num in chosen_nums:
    if num in f_dict:
        f_dict[num] = True
    if num in s_dict:
        s_dict[num] = True
    if num in t_dict:
        t_dict[num] = True

f_rows = list(f_dict.values())
s_rows = list(s_dict.values())
t_rows = list(t_dict.values())
f_cols = [f_rows[0], s_rows[0], t_rows[0]]
s_cols = [f_rows[1], s_rows[1], t_rows[1]]
t_cols = [f_rows[2], s_rows[2], t_rows[2]]

out = 'No'

if all(f_rows) or all(s_rows) or all(t_rows) or all(f_cols) or all(s_cols) or all(t_cols):
    out = 'Yes'
elif f_rows[0] and s_rows[1] and t_rows[2]:
    out = 'Yes'
elif f_rows[2] and s_rows[1] and t_rows[0]:
    out = 'Yes'

print(out)

Submission status: Wrong Answer

Solution code:
a = []
a.append( list( map( int, input().split())))
a.append( list( map( int, input().split())))
a.append( list( map( int, input().split())))

n = int( input())
c = [[0,0,0],[0,0,0],[0,0,0]]
for _ in range(n):
  b = int( input() )
  for i in range(3):
    for j in range(3):
      if a[i][j] == b:
        c[i][j] = 1
        break
bingo_flg = False
for i in range(3):
  if sum(c[i]) == 3:
    bingo_flg= True

for i in range(3):
  if c[i][0] + c[i][1] + c[i][2] == 3:
    bingo_flg= True

if c[0][0] + c[1][1] + c[2][2] == 3:
    bingo_flg= True

if c[2][0] + c[1][1] + c[0][2] == 3:
    bingo_flg= True
  

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
ls = []
count = [0]*9
for i in range(3):
    ls.extend(input().split(' '))
for i in range(int(input())):
    s = input()
    if s in ls:
        i = ls.index(s)
        count[i]="1"
flag = 0
for i in range(3):
    if count[i] == count[i+3] == count[i+6]=="1":
        flag = 1
        break
for i in range(0,8,3):
    if count[i] == count[i+1] == count[i+2] == "1":
        flag = 1
        break
if count[0]==count[4]==count[8]=="1":
    flag = 1
if count[2] == count[4] == count[8] == "1":
    flag = 1
if flag == 1:
    print("Yes")
elif flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
ls = []
count = [0]*9
for i in range(3):
    ls.extend(input().split(' '))
for i in range(int(input())):
    s = input()
    if s in ls:
        i = ls.index(s)
        count[i]="1"

flag = 0
for i in range(3):
    if count[i] == count[i+3] == count[i+6]=="1":
        flag = 1
        break
for i in range(0,8,3):
    if count[i] == count[i+1] == count[i+2] == "1":
        flag = 0
        break
if count[0]==count[4]==count[8]=="1":
    flag = 1
if count[2] == count[4] == count[8] == "1":
    flag = 1
if flag == 1:
    print("Yes")
elif flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [[]*3]*3

for i in range(3):
  a[i] = [int(i) for i in input().split()]

n = int(input())

for i in range(n):
  b = int(input())
  for j in range(3):
    if b in a[j]:
      for k in range(3):
        if b == a[j][k]:
          a[j][k] = 0
          break
b = 0          
for i in range(3):
  if a[i] == 0:
    b += 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
    b += 1
    break
  elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    b += 1
    break
  elif a[2][0] == 0 and a[1][1] == 0 and a[0][2] == 0:
    b += 1
    break

if b == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
#input
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
N = int(input())
B = [0] * N
for j in range(N):
    B[j] = int(input())

#output
if ((a and b and c) in B) or ((d and e and f) in B) or ((g and h and i) in B) or ((a and d and g) in B) or ((b and e and h) in B) or ((c and f and i) in B) or ((a and e and i) in B) or ((c and e and g) in B):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    f = [[False] * (N) for i in range(N)]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i] == A[j][k]:
                    f[j][k] = True
    t = False
    for i in range(3):
        if all([f[i][k] for k in range(3)]):
            t = True

    for i in range(3):
        if all([f[k][i] for k in range(3)]):
            t = True
    
    if all([f[k][k] for k in range(3)]):
        t = True

    if t:
        print(YES)
    else:
        print(NO)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#input
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
N = int(input())
B = [0] * N
for j in range(N):
    B[j] = int(input())

#output
if (a and b and c) or (d and e and f) or (g and h and i) or (a and d and g) or (b and e and h) or (c and f and i) or (a and e and i) or (c and e and g) in B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
h, i, j = map(int, input().split())
N = int(input())
B = [0] * N
for i in range(N):
    B[i] = int(input())

#output
if (a and b and c) in B or (d and e and f) in B or (h and i and j) in B or (a and d and h) in B or (b and e and i) in B or (c and f and j) in B or (a and e and j) in B or (c and e and h) in B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#input
a, B, c = map(int, input().split())
d, e, f = map(int, input().split())
h, i, j = map(int, input().split())
N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())

#output
if a and B and c in b:
    print("Yes")
elif d and e and f in b:
    print("Yes")
elif h and i and j in b:
    print("Yes")
elif a and d and h in b:
    print("Yes")
elif B and e and i in b:
    print("Yes")
elif c and f and j in b:
    print("Yes")
elif a and e and j in b:
    print("Yes")
elif c and e and h in b:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#input
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
h, i, j = map(int, input().split())
N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())

#output
if a and b and c in b:
    print("Yes")
elif d and e and f in b:
    print("Yes")
elif h and i and j in b:
    print("Yes")
elif a and d and h in b:
    print("Yes")
elif b and e and i in b:
    print("Yes")
elif c and f and j in b:
    print("Yes")
elif a and e and j in b:
    print("Yes")
elif c and e and h in b:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
l = [list(map(int, input().split())) for i in range(3)]
n = int(input())
m = [int(input()) for i in range(n)]
c = [[False, False, False], [False, False, False], [False, False, False]]
ans = False
for k in range(n):
    for i in range(3):
        for j in range(3):
            if m[k] == l[i][j]:
                c[i][j] = True
for i in range(3):
    ans = ans or c[i].count(True) == 3
    ans = ans or [c[i][0], c[i][1], c[i][2]].count(True) == 3
ans = ans or [c[0][0], c[1][1], c[2][2]].count(True) == 3
ans = ans or [c[2][0], c[1][1], c[0][2]].count(True) == 3
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

def judge(bingo , lot_list):
    
    result = 0
            
    same_map = []
    for high in range(len(bingo)):
        same_flag = 0
        for wide in range(len(bingo[high])):
            if high == wide:
                if bingo[high][wide] in lot_list:
                    same_flag = 1
        same_map.append(same_flag)
    
    # print(same_map)
    
    if not 0 in same_map:
        result = 1
            
    same_map = []
    for high in range(len(bingo)):
        same_flag = 0
        for wide in range(len(bingo[high])):
            if high + wide == 2:
                if bingo[high][wide] in lot_list:
                    same_flag = 1
        same_map.append(same_flag)
    # print(same_map)
    
    if not 0 in same_map:
        result = 1
    
    flag_list = []
    for num in bingo:
        flag = 1
        for judge_num in num:
            if int(judge_num) in lot_list:
                flag = flag + 1
        flag_list.append(flag)
    # print(flag_list)
    
    if 3 in flag_list:
        result = 1
    
    flag_list = []
    
    bingo = bingo.T
    # print(bingo)
    
    for num in bingo:
        flag = 1
        for judge_num in num:
            if int(judge_num) in lot_list:
                flag = flag + 1
        flag_list.append(flag)
    # print(flag_list)
    
    if 3 in flag_list:
        result = 1
    
    return result
def main():
    bingo_card = []
    
    for high in range(3):
        bingo_wide = []
        info_wide = input()
        info_wide = info_wide.split()
        for wide in info_wide:
            bingo_wide.append(int(wide))
        bingo_card.append(bingo_wide)
    
    lottely_num = int(input())
    lottely_list = []
    for num in range(lottely_num):
        lottely_list.append(int(input()))
    # print(lottely_list)
    
        
    bingo_card = np.array(bingo_card)
    result = judge(bingo_card , lottely_list)
    
    if result == 1:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve(A, N, b):
    for i in range(3):
      for j in range(3):
        if A[i][j] in b and A[i+1][j] in b and A[i+2][j] in b:
            return 'Yes'
        if A[i][j+1] in b and A[i][j+1] in b and A[i][j+2] in b:
            return 'Yes'
        if A[i][j] in b and A[i+1][j+1] in b and A[i+2][j+2] in b:
            return 'Yes'
        return 'No'


def main():
    A = [read_int_list() for i in range(3)]
    N = read_int()
    b = [read_int() for k in range(N)]
    
    res = solve(A, N, b)
    print(res)


main()

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if a[i][j] in bl:
            a[i][j]=0
flag=False
for i in range(3):
    total=0
    if sum(a[i])==0:
        flag=True
        break
    for j in range(3):
        total+=a[j][i]
        if total==0:
            flag=True
            break
    if flag:
        break
if a[0][0]+a[1][1]+a[2][2]==0:
    flag=True
elif a[2][0]+a[1][1]+a[0][2]==0:
    flag=True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

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

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

is_bingo = False
if t_or_f[0][0] and t_or_f[1][1] and t_or_f[2][2]:
  is_bingo = True
elif t_or_f[0][2] and t_or_f[1][1] and t_or_f[2][0]:
  is_bingo = True
else:
  for i in range(3):
    if t_or_f[i][0] and t_or_f[i][0] and t_or_f[i][0]: is_bingo = True
    if t_or_f[0][i] and t_or_f[0][i] and t_or_f[0][i]: is_bingo = True

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = []
for x in range(3):
    bingo = list(int(i) for i in input().split())
    a.append(bingo)
N = int(input())
bingolist=[]
for x in range(N):
    c = int(input())
    bingolist.append(c)
b = [[0]*3 for i in range(3)]

for x in bingolist:
    for y in range(3):
        for z in range(3):
            if a[y][z] == x:
                b[y][z] = 1

bingo_tate =0
bingo_naname = 0
bingo_yoko =0
bingo_kakutei =0

for y in range(3):
    if sum(b[y]) == 3:
        bingo_kakutei=1
alist =[]
for x in range(3):
    a_l = [b[0][x],b[1][x],b[2][x]]
    alist.append(a_l)
for x in range(3):
    if sum(alist[x]) == 3:
        bingo_kakutei=1
        
naname = b[0][0]+b[1][1]+b[2][2]
naname2 = b[0][2]+b[1][1]+b[2][0]
if naname==3 or naname2 ==3:
    bingo_kakutei =1
    
if bingo_kakutei ==1:
    print("Yes")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
a = []
for x in range(3):
    bingo = list(int(i) for i in input().split())
    a.append(bingo)
N = int(input())
bingolist=[]
for x in range(N):
    c = int(input())
    bingolist.append(c)
b = [[0]*3 for i in range(3)]

for x in bingolist:
    for y in range(3):
        for z in range(3):
            if a[y][z] == x:
                b[y][z] = 1

bingo_tate =0
bingo_naname = 0
bingo_yoko =0
bingo_kakutei =0

for y in range(3):
    if sum(b[y]) == 3:
        bingo_kakutei=1
alist =[]
for x in range(3):
    a_l = [b[0][x],b[1][x],b[2][x]]
    alist.append(a_l)
for x in range(3):
    if sum(alist[y]) == 3:
        bingo_kakutei=1
naname = b[0][0]+b[1][1]+b[2][2]
naname2 = b[0][2]+b[1][1]+b[2][0]
if naname==3 or naname2 ==3:
    bingo_kakutei =1
    
if bingo_kakutei ==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 = []
for i in range(n):
    b.append(int(input()))

V = [[False,False,False],[False,False,False],[False,False,False]]

for i in b:
    for i in range(len(A)):
        for j in range(len(A[i])):
            if(A[i][j] == i):
                V[i][j] = True


def judge(V):
    for i in range(3):
        if(V[i][0] and V[i][1] and V[i][2]):
            return True
        if(V[0][i] and V[1][i] and V[2][i]):
            return True

    if(V[0][0] and V[1][1] and V[2][2]):
        return True
    if (V[0][2] and V[1][1] and V[2][0]):
        return True
    return False

if(judge(V)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
 
num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
a1, a2, a3, a4 = 0, 0, 0, 0
for j in range(3):
  a1, a2 = 0, 0
  for i in range(3):
    if(a[i][j] != 0):
      a1 = -1
    if(a[j][i] != 0):
      a2 = -1
    if(a1 == -1 and a2 == -1 and a3 == -1 and a4 == -1):
      print('No')
      exit()
  if(a[j][j] != 0):
    a3 = -1
  if(a[j][2-j] != 0):
    a4 = -1
if(a1 == -1 and a2 == -1 and a3 == -1 and a4 == -1):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
bingo = []
checks = {}
for i in range(3):
    a, b, c = map(int,input().split())
    bingo.append(a)
    bingo.append(b)
    bingo.append(c)
    
n = int(input())
numbers = [int(input()) for i in range(n)]

for number in numbers:
    if number in bingo:
        l = bingo.index(number)
        bingo[l] = 0
        
result = "No"

for i in range(3):
    if sum(bingo[i:3 + i])==0:
        result = "Yes"

for i in range(3):     
    if sum(bingo[i::3])==0:
        result = "Yes"

if sum(bingo[2:7:2]) == 0 :
    result = "Yes"
    
if sum(bingo[0::4]) == 0:
    result = "Yes"
    
print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np

def check(a,b,c):
  return a==b==c==0


t=[list(map(int,list(input().split(" ")))) for i in range(3)]
n = int(input())
a = [int(input()) for _ in range(n)]

for i in a:
  for x in range(3):
    for y in range(3):
      if t[x][y] == i :
        t[x][y] = 0

ans = check(t[0][0],t[0][1],t[0][2]) or \
check(t[1][0],t[1][1],t[1][2]) or \
check(t[2][0],t[2][1],t[2][2]) or \
check(t[0][0],t[1][0],t[2][0]) or \
check(t[0][1],t[1][1],t[2][1]) or \
check(t[0][2],t[1][2],t[2][2]) or \
check(t[0][0],t[1][1],t[2][2]) or \
check(t[0][2],t[1][1],t[2][0]) 

print(ans)

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

#list = [[0] * 3] * 3
list = [ [0]*3 for x in range( 0, 3 ) ]
flag = 0

# print(list)

for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if bingo[i][j] == b[k]:
                list[i][j] = 1
                print(list)
                print(b[k])
# print(list)
# list = [[1,0,0], [1, 1, 0], [0,0,1]]

for i in range(0, 3):
    hantei = 0
    for j in range(0, 3):
        hantei = hantei + list[i][j]
    if hantei == 3:
        flag = 1
        break

for i in range(0, 3):
    hantei = 0
    for j in range(0, 3):
        hantei = hantei + list[j][i]
    if hantei == 3:
        flag = 1
        break

hantei = 0
for i in range(0, 3):
    hantei = hantei + list[i][i]
if hantei == 3:
    flag = 1

hantei = 0
for i in range(0, 3):
    hantei = hantei + list[i][2 - i]
if hantei == 3:
    flag = 1

if flag == 1:
    print('Yes')
elif flag == 0:
    print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
bingo =[]

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

N = input()


for i in range(int(N)):
    bn = int(input())
    
    for i in range(3):
        for j in range(3):
            if(bn == bingo[i][j]):
                bingo[i][j] = -1
        
    

hantei = "No"
for i in range(3):
    if(bingo[0][i] + bingo[0][i] + bingo[0][i] < -2):
        hantei = "Yes"
    
for i in range(3):
    if(bingo[i][0] + bingo[i][1] + bingo[i][2] < -2):
        hantei = "Yes"
  
if(bingo[0][0] + bingo[1][1] + bingo[2][2] < -2):
        hantei = "Yes"
elif(bingo[0][2] + bingo[1][1] + bingo[2][0] < -2):
        hantei = "Yes"


print(hantei)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
bingo =[]

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

N = input()

b = []

for i in range(int(N)):
    bn = int(input())
    b.append(bn)
    
    for i in range(3):
        for j in range(3):
            if(bn == bingo[i][j]):
                bingo[i][j] = -1
        
    

hantei = "No"
for i in range(3):
    if(bingo[0][i] + bingo[0][i] + bingo[0][i] < -2):
        hantei = "Yes"
    
for i in range(3):
    if(bingo[i][0] + bingo[i][1] + bingo[i][2] < -2):
        hantei = "Yes"
  
if(bingo[0][0] + bingo[1][1] + bingo[2][2] < -2):
        hantei = "Yes"
elif(bingo[0][2] + bingo[1][1] + bingo[2][0] < -2):
        hantei = "Yes"


print(hantei)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
bingo =[]

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

N = input()

b = []

for i in range(int(N)):
    bn = int(input())
    b.append(bn)
    
    for i in range(3):
        for j in range(3):
            if(bn == bingo[i][j]):
                bingo[i][j] = -1
        
    

hantei = "No"
for i in range(3):
    if(bingo[0][i] + bingo[0][i] + bingo[0][i] < 1):
        hantei = "Yes"
    
for i in range(3):
    if(bingo[i][0] + bingo[i][1] + bingo[i][2] < 1):
        hantei = "Yes"
  
if(bingo[0][0] + bingo[1][1] + bingo[2][2] < 1):
        hantei = "Yes"
elif(bingo[0][2] + bingo[1][1] + bingo[2][0] < 1):
        hantei = "Yes"


print(hantei)