Problem:


Score : 200 points

Problem Statement

We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.

The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints

All values in input are integers.

1 \leq A_{i, j} \leq 100

A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

A_{1, 1} A_{1, 2} A_{1, 3}
A_{2, 1} A_{2, 2} A_{2, 3}
A_{3, 1} A_{3, 2} A_{3, 3}
N
b_1
\vdots
b_N

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.



Sample input:
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for k in range(n):
  s=int(input())
  for i in range(3):
    for j in range(3):
      if s == A[i][j]:
        A[i][j]=0   
for i in range(3):
  if A[i][0]==0 and A[i][2]==0 and A[i][2]==0:
    print("Yes")
    break
  elif A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
    print("Yes")
    break
  elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    print("Yes")
    break
  elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    print("Yes")
    break
  else:
    print("No")
    break

Submission status: Wrong Answer

Solution code:
import numpy as np
A = np.zeros((3,3), dtype = "int")
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 = [int(input()) for i in range(N)]
for i in range(3):
	for j in range(3):
		for k in range(N):
			if A[i,j] == b[k]:
				A[i,j] = 0
if (A[0,0] == 0 and A[0,1] == 0 and A[0,2] ==0) or (A[1,0] == 0 and A[1,1] and A[1,2] == 0) or (A[2,0] ==0 and A[2,1] ==0 and A[2,2] == 0) or (A[0,0] == 0 and A[1,1] == 0 and A[2,2] == 0) or (A[2,0] == 0 and A[1,1] == 0 and A[0,2] == 0) or (A[0,0] == 0 and A[1,0] == 0 and A[2,0] == 0) or (A[0,1] == 0 and A[1,1] == 0 and A[2,1] == 0) or (A[0,2] == 0 and A[1,2] == 0 and A[2,2] == 0):
	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')
    # 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:
bingo = []
for i in range(3):
    bingo.append(list(map(int, input().split())))
N = int(input())
b = [int(input()) for i in range(N)]


bingoFlag = []
for i in range(3):
    bingoFlage = []
    for j in range(3):
        if bingo[i][j] in b:
            bingoFlage.append(True)
        else:
            bingoFlage.append(False)
    bingoFlag.append(bingoFlage)
# print(bingoFlag)

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

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 any(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:
lines = [input().split() for i in range(3)]
 
num = int(input())
bs = []
for i in range(num):
  bs.append(input())
 
hits = []
for i in bs:
  for row_index in range(len(lines)):
    for col_index in range(len(lines[row_index])):
      if lines[row_index][col_index] == i:
        hits.append((row_index,col_index))
row_hits = [0,0,0]
col_hits = [0,0,0]
stride_hits = [0,0]
 
for hit in hits:
  r = hit[0]
  c = hit[1]
  row_hits[r]+=1
  col_hits[c]+=1
  if r == c:
    stride_hits[0]+=1
  elif (r,c) == (0,2) or (r,c) == (1,1) or (r,c) == (2,0) :
    stride_hits[1]+=1
 
if max(row_hits)>= 3 or max(col_hits)>=3 or max(stride_hits)>= 3:
  print ('Yes')
else:
  print ('No')

Submission status: Wrong Answer

Solution code:
a,b,c = [input().split() for i in range(3)]

a.extend(b)
a.extend(c)
N = int(input())
b = [input() for i in range(N)]
for b1 in b:
    a = ['a' if b1 == s in s else s for s in a]

if a[0] == 'a' and a[1] == 'a' and a[2] == 'a':
    print("Yes")
elif a[3] == 'a' and a[4] == 'a' and a[5] == 'a':
    print("Yes")
elif a[6] == 'a' and a[7] == 'a' and a[8] == 'a':
    print("Yes")
elif a[0] == 'a' and a[3] == 'a' and a[6] == 'a':
    print("Yes")
elif a[1] == 'a' and a[4] == 'a' and a[7] == 'a':
    print("Yes")
elif a[2] == 'a' and a[5] == 'a' and a[8] == 'a':
    print("Yes")
elif a[0] == 'a' and a[4] == 'a' and a[8] == 'a':
    print("Yes")
elif a[2] == 'a' and a[4] == 'a' and a[6] == 'a':
    print("Yes")

Submission status: Wrong Answer

Solution code:
class CircularQueue(): 
  
    # constructor 
    def __init__(self, size): # initializing the class 
        self.size = size 
          
        # initializing queue with none 
        self.queue = [None for i in range(size)]  
        self.front = self.rear = -1
  
    def enqueue(self, data): 
          
        # condition if queue is full 
        if ((self.rear + 1) % self.size == self.front):  
            print(" Queue is Full\n") 
              
        # condition for empty queue 
        elif (self.front == -1):  
            self.front = 0
            self.rear = 0
            self.queue[self.rear] = data 
        else: 
              
            # next position of rear 
            self.rear = (self.rear + 1) % self.size  
            self.queue[self.rear] = data 
              
    def dequeue(self): 
        if (self.front == -1): # codition for empty queue 
            print ("Queue is Empty\n") 
              
        # condition for only one element 
        elif (self.front == self.rear):  
            temp=self.queue[self.front] 
            self.front = -1
            self.rear = -1
            return temp 
        else: 
            temp = self.queue[self.front] 
            self.front = (self.front + 1) % self.size 
            return temp 
  
    def display(self): 
      
        # condition for empty queue 
        if(self.front == -1):  
            print ("Queue is Empty") 
  
        elif (self.rear >= self.front): 
            print("Elements in the circular queue are:",  
                                              end = " ") 
            for i in range(self.front, self.rear + 1): 
                print(self.queue[i], end = " ") 
            print () 
  
        else: 
            print ("Elements in Circular Queue are:",  
                                           end = " ") 
            for i in range(self.front, self.size): 
                print(self.queue[i], end = " ") 
            for i in range(0, self.rear + 1): 
                print(self.queue[i], end = " ") 
            print () 
  
        if ((self.rear + 1) % self.size == self.front): 
            print("Queue is Full")

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for i in range(3)]
a = int(input())
q=[int(input()) for j in range(a)]
k=[[0]*3]*3
for t in range(3):
 for y in range(3):
  if l[t][y] in q:
   k[t][y] = 1
if (k[0][1] == 1 and k[0][2] == 1 and k[0][0] == 1) or (k[1][1] == 1 and k[1][2] == 1 and k[1][0] == 1) or (k[2][1] == 1 and k[2][2] == 1 and k[2][0] == 1) or (k[0][0] == 1 and k[1][0] == 1 and k[2][0] == 1) or (k[0][1] == 1 and k[1][1] == 1 and k[2][1] == 1) or (k[0][2] == 1 and k[1][2] == 1 and k[2][2] == 1) or (k[0][0] == 1 and k[1][1] == 1 and k[2][2] == 1) or (k[0][2] == 1 and k[1][1] == 1 and k[2][0] == 1):
 print("Yes")
else:
 print("No")

Submission status: Wrong Answer

Solution code:
#Input
l_A =  [[0 for i in range(3)] for j in range(3)]
l_A[0] = list(map(int, input().split()))
l_A[1] = list(map(int, input().split()))
l_A[2] = list(map(int, input().split()))
N = int(input())

def detect_BINGO(l_Atf):
    #横
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            return True
    #縦
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[j][i]
        if(f_detect):
            return True
    #斜
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[3-1-i][3-1-i]
    if(f_detect):
        return True
    
    #BINGOなし
    return False

#Process
l_Atf = [[False for i in range(3)] for j in range(3)]
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if(l_A[j][k] == b):
                l_Atf[j][k] = True

f_bingo = detect_BINGO(l_Atf)

#Output
if(f_bingo):
    print("Yes")
else:
    print("no")

Submission status: Wrong Answer

Solution code:
def hasTri(arrs):
    k = [arrs[0][0], arrs[1][1], arrs[2][2]]
    if not False in k:
        return True
    return False
def hascol(arrs):
    for i in range(3):
        k = [arrs[0][i], arrs[1][i], arrs[2][i]]
        if not False in k:
            return True
    return False
def hasrow(arrs):
    for i in arrs:
        arr = [x for x in i if x != False]
        if len(arr)==3:
            return True
    return False
A = [[0,0,0],[0,0,0],[0,0,0]]
B = [[False,False,False],[False,False,False],[False,False,False]]
for i in range(3):
    A[i][0],A[i][1],A[i][2] = map(int, input().split())
N = int(input())
Al = [i for x in A for i in x]
have = []
for _ in range(N):
    a = int(input())
    if a in Al:
        have.append(a)
indexs = [[]]
for k in have:
    index = [[ix,iy] for ix, row in enumerate(A) for iy, j in enumerate(row) if j == k]
    if len(index[0]) == 2:
        indexs = indexs + index
        B[index[0][0]][index[0][1]] = k
if hasTri(B) or hasrow(B ) or hascol(B):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A11, A12, A13 =(int(x) for x in input().split())
A21, A22, A23 =(int(x) for x in input().split())
A31, A32, A33 =(int(x) for x in input().split())

N = int(input())

b_list = list()
for i in range(0,N):
    i = int(input())
    b_list.append(i)

A_list = [A11, A12, A13, A21, A22, A23, A31, A32, A33]

for b in b_list:
    for i in range(0,9):
        if A_list[i] == b:
            A_list[i] = 0

X = 0
for i in range(0,3):
    k = 3*i
    if A_list[k] + A_list[k+1] + A_list[k+2] == 0: X = X + 1
    elif A_list[i] + A_list[i+3] + A_list[i+6] == 0: X = X + 1
    elif A_list[0] + A_list[4] + A_list[8] == 0: X = X + 1
    elif A_list[2] + A_list[4] + A_list[6] == 0: X = X + 1
    else : continue

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

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 any(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 _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

for b in B:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = -100
print(A)
f = False
for i in range(3):
  s = 0
  for j in range(3):
    s += A[i][j]
  if s == -300:
    f = True
for i in range(3):
  s = 0
  for j in range(3):
    s += A[j][i]
  if s == -300:
    f = True
s = 0
for i in range(3):
  s += A[i][i]
  if s == -300:
    f = True
s = 0
for i in range(3):
  s += A[i][2-i]
  if s == -300:
    f = True
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=set([int(input()) for _ in range(n)])
nums=set(a[0]+a[1]+a[2])
b=list(b.intersection(nums))

bingo=[]
bingo+=a
for i in range(3):
  t=[]
  for j in range(3):
    t.append(a[i][j])
  bingo.append(t)

bingo.append([a[0][0],a[1][1],a[2][2]])
bingo.append([a[2][0],a[1][1],a[0][2]])

for i in range(len(b)):
  for j in bingo:
    if b[i] in j:
      j.remove(b[i])

if [] in bingo:
  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==-1 or p==-1:
        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('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))
c1=[a1[0],a2[0],a3[0]]
c2=[a1[1],a2[1],a3[1]]
c3=[a1[2],a2[2],a3[2]]
if all(a1) in b or all(a2) in b or all(a3) in b:
    print('Yes')
elif all(c1) in b or all(c2) in b or all(c3) in b:
    print('Yes')
elif a1[0]and a2[1]and a3[2] in b or a1[2]and a2[1]and a3[0] in b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
aa = list(map(int,input().split()))
aaa = list(map(int,input().split()))
A = []
A.append(a)
A.append(aa)
A.append(aaa)
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))
c = []
ans = 0
if (A[0] in b) or (A[1] in b) or (A[2] in b):
    ans += 1
elif (A[0][0] in b) and (A[1][1] in b) and (A[2][2] in b):
    ans += 1
elif (A[0][2] in b) and (A[1][1] in b) and (A[2][0] in b):
    ans += 1
for i in range(3):
    for j in range(3):
        c.append(A[j][i])
    if c in b:
        ans += 1
    c.clear()
if ans == 0:
    print("No")
else:
    print("Yes")

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")
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:
import numpy as np
A = np.zeros((3,3), dtype = "int")
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 = [int(input()) for i in range(N)]
for i in range(3):
	for j in range(3):
		for k in range(N):
			if A[i,j] == b[k]:
				A[i,j] = 0
if (A[0,0] == 0 and A[0,1] == 0 and A[0,2] ==0) or (A[1,0] == 0 and A[1,1] and A[1,2] == 0) or (A[2,0] ==0 and A[2,1] ==0 and A[2,2] == 0) or (A[0,0] == 0 and A[1,1] == 0 and A[2,2] == 0) or (A[2,0] == 0 and A[1,1] == 0 and A[0,2] == 0):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import re, sys

A = np.zeros((3,3), dtype=int)
for i in range(3):
  row = input()
  nums = re.split(' ', row)
  for j in range(3):
  	A[i, j] = int(nums[j])
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
for i in range(3):
  if len(set(A[i]) & set(b)) == 3 | len(set(A[:,i]) & set(b)) == 3:
    print('Yes')
    sys.exit()
cross1 = [A[0,0] ,A[1,1], A[2,2]]
cross2 = [A[0,2] ,A[1,1], A[2,0]]
if len(set(cross1) & set(b)) == 3 | len(set(cross2) & set(b)) == 3:
  print('Yes')
  sys.exit()
else:
  print('Noooo')

Submission status: Wrong Answer

Solution code:
import operator
from functools import reduce

l = []
for i in range(3):
    i = list(map(int, input().split()))
    l.append(i)
i_list = reduce(operator.concat, l)

num_input = int(input())

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

my_match_list = list(set(i_list).intersection(set(b_list)))
print(my_match_list)

if len(my_match_list) >= 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
f = np.zeros((3, 3))
b = np.zeros((3, 3))
f[0]=list(map(int,input().split()))
f[1]=list(map(int,input().split()))
f[2]=list(map(int,input().split()))
n= int(input())
for i in range(n):
  c = int(input())
  b=np.where(f == c, b + 1, b)
  #print(b)
b=np.where(b > 0, 1, 0)
#print(b)
if all(b[0][:]) or all(b[1][:]) or all(b[2][:])\
or all(b[:][0]) or all(b[:][1]) or all(b[:][2])\
or all((b[0][0],b[1][1],b[2][2])) or all((b[0][2],b[1][1],b[2][0])):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

Bingo = False


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


for i in range(3):
    for j in range(3):
        if A[i][j] == 9999:
            Bingo = True
        
        

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

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 any(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 = []
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')
  elif '4' in match:
    if '8' in match:
      print('Yes')
elif '1' in match:
  if '4' in match:
    if '7' in match:
      print('Yes')
elif '2' in match:
  if '4' in match:
    if '6' in match:
      print('Yes')
  elif '5' in match:
    if '8' in match:
      print('Yes')
else:
  print('No')

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 [0, 3, 6]:
    print(i)
    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:
l=[]
for i in range(3):
        l.extend(list(map(int,input().split())))

n = int(input())
b = [int(input()) for i in range(n)]
c = []
for ii in range(n):
    for iii in range(9):
        if b[ii] == l[iii]:
            c.append(iii)
            break
flag = 'No'
for j in range(3):
    if 3*i in c and 3*i+1 in c and 3*i+2 in c:
        flag = 'Yes'
        break
    if i in c and 3+i in c and 6+i in c:
        flag = 'Yes'
        break
if 0 in c and 4 in c and 8 in c:
    flag = 'Yes'
elif 2 in c and 4 in c and 6 in c:
    flag = 'Yes'

print(flag)

Submission status: Wrong Answer

Solution code:
A = list(map(str, input().split()))
A += list(map(str, input().split()))
A += list(map(str, input().split()))
a = []
N = int(input())
for i in range(N):
    a.append(input())
flag = 0
for i  in a:
    if i in A:
        A[A.index(i)] = "0"
B = []
C = []
for i in range(3):
    B.append(A[4*i])
    C.append(A[2*i])
    if "0" in A[i*3:i*3+3]:
        if A.count("0") == 3:
            flag = 1
if "0" in B:
    if B.count("0") == 3:
        flag = 1
if"0"in C:
    if C.count("0") == 3:
        flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
tate1=[A1[0],A2[0],A3[0]]
tate2=[A1[1],A2[1],A3[1]]
tate3=[A1[2],A2[2],A3[2]]
naname1=[A1[0],A2[1],A3[2]]
naname2=[A1[2],A2[1],A3[0]]

if A1[0] and A1[1] and A1[2] in b:
    print('Yes')
    sys.exit()
if A2[0] and A2[1] and A2[2] in b:
    print('Yes')
    sys.exit()
if A3[0] and A3[1] and A3[2] in b:
    print('Yes')
    sys.exit()
if tate1[0] and tate1[1] and tate1[2] in b:
    print('Yes')
    sys.exit()
if tate2[0] and tate2[1] and tate2[2] in b:
    print('Yes')
    sys.exit()
if tate3[0] and tate3[1] and tate3[2] in b:
    print('Yes')
    sys.exit()
if naname1[0] and naname1[1] and naname1[2] in b:
    print('Yes')
    sys.exit()
if naname2[0] and naname2[1] and naname2[2] in b:
    print('Yes')
    sys.exit()
print('No')

Submission status: Wrong Answer

Solution code:
A = [input().split() for x in range(3)]
N = int(input())
B = [int(input()) for y in range(N)]
index1 = 0
index2 = 0
count1 = 0
count2 = 0
index1 = 0
matches = 0
Match = []
i = 0
for number in B:
  for n in A:
    for m in n:
      if int(m) == number:
        Match.append([count1, count2])
      count2 += 1
    count1 += 1
    count2 = 0
  count1 = 0
for l in Match:
  matches += 1
if matches == 0:
  print("No")
  exit()
while i <= matches:
  for L in Match:
    for LL in L:
      for M in Match:
        for MM in M:
          if MM == LL:
            print("Yes")
            exit()
          else:
            print("No")
            exit()
  i += 1

Submission status: Wrong Answer

Solution code:
import numpy as np


A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = np.array([])
for _ in range(N):
    b = np.append(b, int(input()))
    
A = np.array([A1, A2, A3])
index = np.zeros((3,3))
for i in b:
  index += np.array(A==i, dtype=np.int)
sum2 = 0


for i in range(3):
  sum1 = np.sum(index[i])
  if sum1 >= 3:
    ans1 = 1
  else:
    ans1 = 0
for i in range(3):
  for j in range(3):
    sum2 += index[i][j]
    if sum2 >= 3:
      ans2 = 1
    else:
      ans2 = 0
if np.trace(index) >= 3:
  ans3 = 1
else:
  ans3 = 0
index = index[:, ::-1]
if np.trace(index) >= 3:
  ans4 = 1
else:
  ans4 = 0

y = ans1 + ans2 + ans3 + ans4
if y == 0:
  print("No")
else:
  print("Yes")

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 or 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 or 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:
# -*- 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[i][0] == 0 & a[i][1] == 0 & a[i][2] == 0):
            print('Yes')
            exit()
        if a[i] == [0, 0, 0]:
            print('Yes')
            exit()
    print('No')

check(a)

Submission status: Wrong Answer

Solution code:
import sys

f = sys.stdin

l1 = f.readline().rstrip().split(" ")
l2 = f.readline().rstrip().split(" ")
l3 = f.readline().rstrip().split(" ")

mat = l1 + l2 + l3

f.readline()  #skip N
nums = []
for line in f.readlines():
    nums.append(line.rstrip())


#check
def check(kohos, n1, n2, n3):
    kohos = set(kohos)
    if n1 in kohos:
        if n2 in kohos:
            if n3 in kohos:
                #return True
                print("Yes", end="")
                quit()
    return False


#all patterns..
check(nums, mat[0], mat[1], mat[2])
check(nums, mat[3], mat[4], mat[5])
check(nums, mat[6], mat[7], mat[8])

check(nums, mat[0], mat[3], mat[6])
check(nums, mat[1], mat[4], mat[7])
check(nums, mat[2], mat[5], mat[8])

check(nums, mat[0], mat[4], mat[5])
check(nums, mat[2], mat[4], mat[6])
print("No", end="")