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 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)
# print(master.count('3'))
for e in master:
    if e==3:
        print('Yes')
        exit()
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, 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:

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

    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[1][j] = True
            if A[2][j] == i:
                flags[2][j] = True
            
            if A[j][0] == i:
                flags[j][0] = True
            if A[j][1] == i:
                flags[j][1] = True
            if A[j][2] == i:
                flags[j][2] = True

            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:
def judge_bingo(m,a):
    sum_h = 0
    sum_v = 0
    sum_d1 = 0
    sum_d2 = 0
    for i in range(m):
        for j in range(m):
            sum_h += a[i][j]
            sum_v += a[j][i]
        
        if sum_h==3 or sum_v==3:
            return True
        sum_d1 += a[i][i]
        sum_d2 += a[i][-i-1]
        
    if sum_d1==3 or sum_d1==3:
        return True
    else:
        return False
    

if __name__ == "__main__":
    m = 3
    card = [[0]]*m
    bingo = [[0]*m for i in range(3)]
    for i in range(m):
        card[i] = list(map(int,input().split()))
    n = int(input())
    nums = []
    for i in range(n):
        nums.append(int(input()))
        
    sum_h = [0]*m
    for num in nums:
        for i in range(m):
            for j in range(m):
                if card[i][j]==num:
                    bingo[i][j] = 1
    if judge_bingo(m,bingo):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
inputgrid1 = input().split(" ")
inputgrid2 = input().split(" ")
inputgrid3 = input().split(" ")
num = int(input())
bingolist = list()
dialist = list()
dialist.append(inputgrid1[0])
dialist.append(inputgrid2[1])
dialist.append(inputgrid3[2])
length = 0
check = 0
for i in range (0, num):
    inputnum = int(input())
    if inputnum >= 1 and inputnum <= 100:
        inputnum = str(inputnum)
        bingolist.append(inputnum)
    else:
        break
inputlist = list()
bingolist1 = bingolist.copy()
bingolist2 = bingolist.copy()
bingolist3 = bingolist.copy()
for i in inputgrid1:
    bingolist.append(i)
for i in inputgrid2:
    bingolist1.append(i)
for i in inputgrid3:
    bingolist2.append(i)
for i in dialist:
    bingolist3.append(i)
length = num + 3
for i in inputgrid1:
    inputlist.append(i)
for i in inputgrid2:
    inputlist.append(i)
for i in inputgrid3:
    inputlist.append(i)
for i in inputlist:
    i = int(i)
    if i >= 1 and i <= 100:
        check = 0
    else:
        check = 1
        break
con1 = inputgrid1[0] == inputgrid2[1]
con2 = num >= 1 and num <= 10
con3 = len(set(bingolist)) == length and len(set(bingolist1)) == length
con4 = len(set(bingolist2)) == length and len(set(bingolist)) == length
con5 = con3 == True and con4 == True
for i in bingolist:
    inputlist.append(i)
inputlist = set(inputlist)
if con1 == False and con2 == True and check == 0:
    if con5 == True and check == 0:
        print("No")
    else:
        print("Yes")
else:
    print()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
data = [stdin.readline().rstrip().split()for _ in range(3)]
N = int(input())
B = []
for _ in range(N):
    B.append(input())

for b in B:
    for i in range(len(data)):
        for j in range(len(data[i])):
            if data[i][j] == b:
                data[i][j] = "o"

if data[0][0] ==  data[1][1] == data[2][2]:
    print("yes")
    sys.exit()
elif data[0][2] ==  data[1][1] == data[2][0]:
    print("yes")
    sys.exit()
else:
    for i in range(len(data)):
        if data[i][0] ==  data[i][1] == data[i][2]:
            print("yes")
            sys.exit()
        for j in range(len(data[i])):
            if data[0][j] ==  data[1][j] == data[2][j]:
                print("yes")
                sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def main():
    bingo = []
    bingo.append(list(map(int, input().split())))
    bingo.append(list(map(int, input().split())))
    bingo.append(list(map(int, input().split())))
    
    
    bingo += bingo[0][0], bingo[1][0], bingo[2][0]
    
    bingo += bingo[0][0], bingo[1][1], bingo[2][2]
    
    n = int(input())
    num = list()
    for _ in range(n):
        num.append(int(input()))
    
    counter = 0   
    for i in range(8):
        if bingo[i] in num:
            print("Yes")
            break
        else:
            counter += 1
            
    if counter == 8:
        print('No')
                
    return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
 
xy = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
num = [list(map(int, input().split())) for _ in range(n)] 
result = [[0,0,0],[0,0,0],[0,0,0]]

def input_b(xy:list, num:int, result:list):
    for i in range(3):
        if num in xy[i]:
            for j in range(3):
                if num==xy[i][j]:
                    result[i][j]=1
    return result
  
def check_result(result:list):
    for i in range(3):
        if 3 == np.array(result[0]).sum():
            return "Yes" 
    if 3 in np.array(result[0]) + np.array(result[1]) + np.array(result[2]):
        return "Yes"
    if 3 == result[0][0] + result[1][1] + result[2][2]:
        return"Yes"
    if 3 == result[0][2] + result[1][1] + result[2][1]:
        return"yes"
    return "No"
 
for i in num:
    result=input_b(xy,i[0],result)
 
print(check_result(result))

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
e,d,f=map(int,input().split())
g,h,i=map(int,input().split())
bingo = [a,b,c,d,e,f,g,h,i]
a_list= []
yes = 0
N = int(input())
for i in range(0,N):
    b = int(input())
    if b in bingo:
        a_list.append(bingo.index(b))
if 0 in a_list:
    if 1 in a_list:
        if 2 in a_list:
            yes = 1
    if 3 in a_list:
        if 6 in a_list:
            yes = 1
    if 4 in a_list:
        if 8 in a_list:
            yes = 1
if 1 in a_list:
    if 4 in a_list:
        if 7 in a_list:
            yes = 1
if 2 in a_list:
    if 4 in a_list:
        if 6 in a_list:
            yes = 1
    if 5 in a_list:
        if 8 in a_list:
            yes = 1
if 3 in a_list:
    if 4 in a_list:
        if 5 in a_list:
            yes = 1
if 6 in a_list:
    if 7 in a_list:
        if 8 in a_list:
            yes = 1
if yes == 1:
    print("Yes")
if yes == 0:
    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)

    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[j][0] = True
            if A[j][1] == i:
                flags[j][0] = True
            if A[j][2] == i:
                flags[j][0] = True

            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:
A = []
for _ in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

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

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

for i in range(3):
    if (i, 0) in punch:
        if (i, 1) in punch and (i, 2) in punch:
            print('Yes')
            exit()
        if ((i-1), 0) in punch and ((i+1), 0) in punch:
            print('Yes')
            exit()
        if ((i-1), 1) in punch and ((i+1), 2) in punch:
            print('Yes')
            exit()

if (2, 0) in punch:
    if (1, 1) in punch and (0, 2) in punch:
        print('Yes')
        exit()

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[1][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:

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


if __name__ == "__main__":
    ret = "No"
    A1 = input().split()
    A2 = input().split()
    A3 = input().split()
    A = A1 + A2 + A3
    bingo = [False]*len(A)
    N = int(input())
    B = []
    for i in range(N):
        B.append(input())
    for b in B:
        index = find_index(A, b)
        if index:
            bingo[index] = True
    if bingo[4]:
        if bingo[0] and bingo[8]:
            ret = "Yes"
        elif bingo[2] and bingo[6]:
            ret = "Yes"
        elif bingo[1] and bingo[7]:
            ret = "Yes"
        else:
            pass
    for i in range(3):
        if bingo[i]:
            if bingo[i+2] and bingo[i+4]:
                ret = "Yes"
            elif bingo[i:i+2]:
                ret = "Yes"
            else:
                pass
    print(ret)

Submission status: Wrong Answer

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

N = int(input())

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

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

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

if (2, 0) in punch:
    if (1, 1) in punch and (0, 2) in punch:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
A = [a11, a12, a13, a21, a22, a23, a31, a32, a33]
N = int(input())
b = []
for _ in range(N):
    try:
        A[A.index(int(input()))] = '○'
    except ValueError:
        pass

ans = 'No'
if A[0] == '○' and A[1] == '○' and A[2] == '○':
    ans = 'Yes'
if A[3] == '○' and A[4] == '○' and A[5] == '○':
    ans = 'Yes'
if A[6] == '○' and A[7] == '○' and A[8] == '○':
    ans = 'Yes'

if A[0] == '○' and A[3] == '○' and A[6] == '○':
    ans = 'Yes'
if A[1] == '○' and A[4] == '○' and A[7] == '○':
    ans = 'Yes'
if A[2] == '○' and A[5] == '○' and A[8] == '○':
    ans = 'Yes'

if A[0] == '○' and A[4] == '○' and A[8] == '○':
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
inputgrid1 = input().split(" ")
inputgrid2 = input().split(" ")
inputgrid3 = input().split(" ")
num = int(input())
bingolist = list()
dialist = list()
dialist.append(inputgrid1[0])
dialist.append(inputgrid2[1])
dialist.append(inputgrid3[2])
length = 0
check = 0
for i in range (0, num):
    inputnum = int(input())
    if inputnum >= 1 and inputnum <= 100:
        inputnum = str(inputnum)
        bingolist.append(inputnum)
    else:
        break
inputlist = list()
bingolist1 = bingolist.copy()
bingolist2 = bingolist.copy()
bingolist3 = bingolist.copy()
for i in inputgrid1:
    bingolist.append(i)
for i in inputgrid2:
    bingolist1.append(i)
for i in inputgrid3:
    bingolist2.append(i)
for i in dialist:
    bingolist3.append(i)
length = num + 3
for i in inputgrid1:
    inputlist.append(i)
for i in inputgrid2:
    inputlist.append(i)
for i in inputgrid3:
    inputlist.append(i)
for i in inputlist:
    i = int(i)
    if i >= 1 and i <= 100:
        check = 0
    else:
        check = 1
        break
con1 = inputgrid1[0] == inputgrid2[1]
con2 = num >= 1 and num <= 10
con3 = len(set(bingolist)) == length and len(set(bingolist1)) == length
con4 = len(set(bingolist2)) == length and len(set(bingolist)) == length
for i in bingolist:
    inputlist.append(i)
inputlist = set(inputlist)
print(bingolist)
if (con1 == False and con2 == True) and check == 0:
    if con3 == True and con4 == True:
        print("No")
    else:
        print("Yes")
else:
    print()

Submission status: Wrong Answer

Solution code:
import numpy as np
 
xy = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
num = [list(map(int, input().split())) for _ in range(n)] 
result = [[0,0,0],[0,0,0],[0,0,0]]

def input_b(xy:list, num:int, result:list):
    for i in range(3):
        if num in xy[i]:
            for j in range(3):
                if num==xy[i][j]:
                    result[i][j]=1
    return result
  
def check_result(result:list):
    for i in range(3):
        if 3 == np.array(result[0]).sum():
            return "Yes" 
    if 3 in np.array(result[0]) + np.array(result[1]) + np.array(result[2]):
        return "Yes"
    if 3 == result[0][0] + result[1][1] + result[2][2]:
        return"Yes"
    return "No"
 
for i in num:
    result=input_b(xy,i[0],result)
 
print(check_result(result))

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][0] == A[i][1] == A[i][2] == 9999:
            Bingo = True
        elif A[0][j] == A[1][j] == A[2][j] == 9999:
            Bingo = True
        elif A[0][0] == A[1][1] == A[2][2] == 9999:
            Bingo = True
   
if Bingo:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from operator import add
from functools import reduce
arr = []
L_d_count = 0
R_d_count = 0
row_count = 0
col_count = 0
for i in range(3):
    A,B,C = map(int,input().split())
    arr.append([A,B,C])
A = reduce(add ,arr)
L_diagonal = [r[i] for i, r in enumerate(arr)]
R_diagonal = [r[-i-1] for i, r in enumerate(arr)]
col_list = [[A[0],A[3],A[6]],[A[1],A[4],A[7]],[A[2],A[5],A[8]]]
N = int(input())
for j in range(N):
    B = int(input())
    if B in L_diagonal: L_d_count += 1
    if B in R_diagonal: R_d_count += 1
    for k in col_list:
        if B in k: col_count += 1
    for m in arr:
        if B in m: row_count += 1
if L_d_count==3 or R_d_count==3 or col_count==3 or row_count==3:
    print ("Yes")
else: print ("No")

Submission status: Wrong Answer

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

#print("bingo",bingo)

score = [[0,0,0],[0,0,0],[0,0,0]]
total = 0

Input = []
while True:
    try:
        i = list(map(int, input().split()))
        Input += i
    except EOFError:
        break
        
#print("selects",selects)
for select in Input:
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == select:
                score[i][j] = 1
    #print("score", score)
    for i in range(3):
        total += sum(score[i]) == 3
        total += sum(score[:][i]) == 3

    if (score[0][0] + score[1][1] + score[2][2]) == 3:
        total +=1
    if (score[0][2] + score[1][1] + score[2][0]) == 3:
        total +=1
    #print("total",total)
    if total > 0:
        print('Yes')
        break

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

Submission status: Wrong Answer

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

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


print(any([len([j for j in k if j in bs])==3 for k in bingo]))

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
if 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
elif ans > 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
c = [[-1]*3]*3
for i in range(3):
    ai = list(map(int, input().split()))
    a.append(ai)
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                c[j][k] = 0

chk = 0
for i in range(3):
    if c[i][0] == 0 and c[i][1] == 0 and c[i][2] == 0:
        print("Yes")
        chk = 1
        break
if chk == 0:
    for i in range(3):
        if c[0][i] == 0 and c[1][i] == 0 and c[2][i] == 0:
            print("Yes")
            chk = 1
            break
if chk == 0:
    if c[0][0] == 0 and c[1][1] == 0 and c[2][2] == 0:
        print("Yes")
    elif c[0][2] == 0 and c[1][1] == 0 and c[2][0] == 0:
        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
print(A)
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
if 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
elif ans > 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

N = int(input())

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

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

for i in range(3):
    if (i, 0) in punch:
        if (i, 1) in punch and (i, 2) in punch:
            print('Yes')
            exit()
        if (i-1, 0) in punch and (i+1, 0) in punch:
            print('Yes')
            exit()
        if (i+1, 1) in punch and (i+2, 2) in punch:
            print('Yes')
            exit()

if (2, 0) in punch:
    if (1, 1) in punch and (0, 2) in punch:
        print('Yes')
        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:
l1=[int(x) for x in input().rstrip().split()]
l2=[int(x) for x in input().rstrip().split()]
l3=[int(x) for x in input().rstrip().split()]
l=[]

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

for i in l1:
    l.append(i)
for i in l2:
    l.append(i)
for i in l3:
    l.append(i)

n=int(input())
for i in range(n):
    b=int(input())
    a = my_index(l,b)
    if my_index(l,b)!=-1:
        l[a]=0

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

Submission status: Wrong Answer

Solution code:
inputgrid1 = input().split(" ")
inputgrid2 = input().split(" ")
inputgrid3 = input().split(" ")
num = int(input())
bingolist = list()
dialist = list()
dialist.append(inputgrid1[0])
dialist.append(inputgrid2[1])
dialist.append(inputgrid3[2])
length = 0
check = 0
for i in range (0, num):
    inputnum = int(input())
    if inputnum >= 1 and inputnum <= 100:
        inputnum = str(inputnum)
        bingolist.append(inputnum)
    else:
        break
inputlist = list()
bingolist1 = bingolist.copy()
bingolist2 = bingolist.copy()
bingolist3 = bingolist.copy()
for i in inputgrid1:
    bingolist.append(i)
for i in inputgrid2:
    bingolist1.append(i)
for i in inputgrid3:
    bingolist2.append(i)
for i in dialist:
    bingolist3.append(i)
length = num + 3
for i in inputgrid1:
    inputlist.append(i)
for i in inputgrid2:
    inputlist.append(i)
for i in inputgrid3:
    inputlist.append(i)
for i in inputlist:
    i = int(i)
    if i >= 1 and i <= 100:
        check = 0
    else:
        check = 1
        break
con1 = inputgrid1[0] == inputgrid2[1]
con2 = num >= 1 and num <= 10
con3 = len(set(bingolist)) == length and len(set(bingolist1)) == length
con4 = len(set(bingolist2)) == length and len(set(bingolist)) == length
for i in bingolist:
    inputlist.append(i)
inputlist = set(inputlist)
if con1 == False and con2 == True:
    if con3 == True and con4 == True:
        print("No")
    else:
        print("Yes")
else:
    print()

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 = []
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[3*i:3*i+3]:
        if A.count("0") == 3:
            flag = 1
    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:
a = []
for _ in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
b = []
for _ in range(n):
    b.append(int(input()))

box=[[0]*3]*3

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

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

Submission status: Wrong Answer

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

N = int(input())
b = list()
for x in range(N):
    b.append(input())
result = list()
round = 0
for x in range(3):
    for y in range(3):
        if A[x][y] in b:
            result.append(round+y)
    round+=3
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:
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:
    print('Yes')
elif a1[2]and a2[1]and a3[0] in b:
    print('Yes')
else:
    print('No')