Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

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

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

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

Sample Input 2

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

Sample Output 2

No

We will mark nothing.

Sample Input 3

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

Sample Output 3

Yes

We will mark all the squares.



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


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
card = [input().split() for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == num:
                card[i][j] = 0
for i in range(3):
    if  (card[0][i] == 0 and card[1][i] == 0 and card[2][i]) or\
        (card[i][0] == 0 and card[i][1] == 0 and card[i][2]):
        print("Yes")
        exit()
if  (card[0][0] == 0 and card[1][1] == 0 and card[2][2]) or\
    (card[0][2] == 0 and card[1][1] == 0 and card[2][0]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
A_list1 = list(map(int, input().split()))
A_list2 = list(map(int, input().split()))
A_list3 = list(map(int, input().split()))
N = int(input())
B_list = []
for i in range(N):
    B_list.append(int(input()))

A_list1_c = []
A_list2_c = []
A_list3_c = []
for i in B_list:
    if i in A_list1:
        A_list1_c.append(A_list1.index(i))
    if i in A_list2:
        A_list2_c.append(A_list2.index(i))
    if i in A_list3:
        A_list3_c.append(A_list3.index(i))

for i in A_list1_c:
    if i in A_list2_c and i in A_list3_c:
        print("Yes")
        exit()
    if i == 0:
        if 1 in A_list2_c:
            if 2 in A_list3_c:
                print("Yes")
                exit()
    if i == 2:
        if 1 in A_list2_c:
            if 0 in A_list3_c:
                print("Yes")
                exit()
if A_list1_c.count == 3 or A_list2_c.count == 3 or A_list3_c.count == 3:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
def cross_gugge(A):
  if A[0][0] == 1 and A[1][1] == 1 and A[2][2] == 1:
    return True
  elif A[0][2] == 1 and A[1][1] == 1 and A[2][0] == 1:
    return True
  else:
    return False

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
ans += 1 if cross_gugge(A) else 1
if ans > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a1 = na()
a2 = na()
a3 = na()

A = a1+a2+a3
C = [0,0,0,0,0,0,0,0,0]

n = ni()

for i in range(n):
    b = ni()
    if b in A:
        C[A.index(b)] = 1
    if sum(C[0:3]) == 3 or sum(C[3:6])==3 or sum(C[6:9]) == 3 or sum(C[::4]) == 3 or sum(C[2:7:2]) == 3:
        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())
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

def check_bingo(bingo_card):
    bingo_cnt = 0
    bingo_list = [[0, 1, 2],
                  [3, 4, 5],
                  [6, 7, 8],
                  [0, 3, 6],
                  [1, 4, 5],
                  [2, 5, 8],
                  [0, 4, 8],
                  [2, 4, 6],]    

    for i in range(len(bingo_list)):
        for j in range(len(bingo_list[i])):
            if bingo_card[bingo_list[i][j]] == 0:
                bingo_cnt +=1
            else:
                break
        
        if bingo_cnt == 3:
            return(True)
            break
        else:
            bingo_cnt = 0
            return(False)

def main():
    bingo_card = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
    cnt = 0
    for i in range(N):
        for j in range(len(bingo_card)):
            if b[i] == bingo_card[j]:
                bingo_card[j] = 0
                cnt += 1
                break
            else:
                pass

    if cnt <= 2:
        print('No')                
        
    elif 3 <= cnt <= 6:
        judge_bingo = check_bingo(bingo_card)
        if judge_bingo == True:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')                
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
card = [input().split() for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == num:
                card[i][j] = 0
                break
for i in range(3):
    if  (card[0][i] == 0 and card[1][i] == 0 and card[2][i]) or\
        (card[i][0] == 0 and card[i][1] == 0 and card[i][2]):
        print("Yes")
        exit()
if  (card[0][0] == 0 and card[1][1] == 0 and card[2][2]) or\
    (card[0][2] == 0 and card[1][1] == 0 and card[2][0]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
board=[list(map(int,input().split())) for _ in range(3)]
flag=[[False]*3 for _ in range(3)]
n=int(input())
for _ in range(n):
  tmp=int(input())
  for i in range(3):
    for j in range(3):
      if board[i][j]==tmp:
        flag[i][j]=True
if flag[0][0]==True and flag[0][1]==True and flag[0][2]==True:
  print('Yes')
elif flag[1][0]==True and flag[1][1]==True and flag[2][1]==True:
  print('Yes')
elif flag[2][0]==True and flag[2][1]==True and flag[2][2]==True:
  print('Yes')
elif flag[0][0]==True and flag[1][0]==True and flag[2][0]==True:
  print('Yes')
elif flag[0][1]==True and flag[1][1]==True and flag[2][1]==True:
  print('Yes')
elif flag[0][2]==True and flag[1][2]==True and flag[2][2]==True:
  print('Yes')
elif flag[0][0]==True and flag[1][1]==True and flag[2][2]==True:
  print('Yes')
elif flag[0][2]==True and flag[1][1]==True and flag[2][0]==True:
  print('Yes')
else:
  print('No')

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 = []
D = []
E = []
F = []
for i in range(3):
    B.append(A[4*i])
    C.append(A[2*i])
    D.append(A[3*i])
    E.append(A[3*i+1])
    F.append(A[3*i+2])
    if "0" in A[i*3:i*3+3]:
        if A[i*3:i*3+3].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"0"in D:
    if D.count("0") == 3:
        flag = 1
if"0"in E:
    if E.count("0") == 3:
        flag = 1
if"0"in F:
    if F.count("0") == 3:
        flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [input().split() for l in range(3)]
num = int(input())
b = []
for i in range(num):
    b.append(int(input()))

bngflg = False

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[i][j] in b:
            cnt += 1
    if cnt == 3:
        bngflg = True

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[j][i] in b:
            cnt += 1
    if cnt == 3:
        bngflg = True

if int(a[0][0]) in b and int(a[1][1]) in b and int(a[2][2]) in b:
    bngflg = True

if int(a[0][2]) in b and int(a[1][1]) in b and int(a[2][0]) in b:
    bngflg = True

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a1 = na()
a2 = na()
a3 = na()

A = a1+a2+a3
C = [0,0,0,0,0,0,0,0,0]

n = ni()

for i in range(n):
    b = ni()
    if b in A:
        C[A.index(b)] = 1
    if sum(C[0:2]) == 3 or sum(C[3:5])==3 or sum(C[6:8]) == 3 or sum(C[::4])==3 or sum(C[2:7:2])==3:
        print('Yes')
        exit()

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

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[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(int
(input())):
    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:
# coding:utf-8

A1=[int(i) for i in input().split()]
A2=[int(i) for i in input().split()]
A3=[int(i) for i in input().split()]
A=[[0,0,0],[0,0,0],[0,0,0]]
N=int(input())
b=[int(input()) for i in range(N)]

for i in b:
    for a in A1:
        if a==i:
            A[0][A1.index(a)]=1
    for a in A2:
        if a==i:
            A[1][A2.index(a)]=1
    for a in A3:
        if a==i:
            A[2][A3.index(a)]=1
if sum(A[0])==3 or sum(A[1])==3 or sum(A[2])==3 or sum([A[0][0],A[1][0],A[2][0]]) or sum([A[0][1],A[1][1],A[2][1]]) or sum([A[0][2],A[1][2],A[2][2]]) or sum([A[0][0],A[1][1],A[2][2]]) or sum([A[0][2],A[1][1],A[2][0]]):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A = [[],[],[]]
b = []
B = [[False]*3]*3

A[0] = list(map(int,input().split(" ")))
A[1] = list(map(int,input().split(" ")))
A[2] = list(map(int,input().split(" ")))
N = int(input())

_N = N
while(_N>0):
    _N -= 1
    b.append(int(input()))

for c in b:
    for i in range(3):
        for j in range(3):
            if(A[i][j] == c):
                B[i][j] = True

bingo = "No"
# tate
for i in range(3):
    # tate
    if(B[i][0] and B[i][1] and B[i][2]):
        bingo = "Yes"
    # yoko
    if(B[0][i] and B[1][i] and B[2][i]):
        bingo = "Yes"
# naname
if(B[0][0] and B[1][1] and B[2][2]):
    bingo = "Yes"
if(B[0][2] and B[1][1] and B[2][0]):
    bingo = "Yes"

print(bingo)

Submission status: Wrong Answer

Solution code:
a=[input().split() for i in range(3)]
n=int(input())
b=[input() for i in range(n)]
flg=0
for k in range(3):
  if a[k][0] in b:
    if a[k][1] and a[k][2] in b:
      flg=1
  elif a[0][k] in b:
    if a[1][k] and a[2][k] in b:  
      flg=1
if a[0][0] and a[1][1] and a[2][2] in b:
  flg=1
elif a[0][2] and a[1][1] and a[2][0] in b:
  flg=1
print(['No','Yes'][flg])

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

def detect_BINGO(l_Atf):
    #print(l_Atf)
    #横
    for i in range(3):
        f_detect = True
        for j in range(3):
            #print(f_detect, l_Atf[i][j])
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            #print("横" + str(i))
            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):
            #print("縦" + str(i))
            return True
    #斜
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        #print("斜＼")
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][3-1-i]
    if(f_detect):
        #print("斜／")
        return True
    
    #BINGOなし
    return 

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

f_bingo = detect_BINGO(l_Atf)

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

Submission status: Wrong Answer

Solution code:
card = [input().split() for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == num:
                card[i][j] = 0
                break
for i in range(3):
    if  (card[0][i] == 0 and card[1][i] == 0 and card[2][i]) or\
        (card[0][i] == 0 and card[1][i] == 0 and card[2][i]) or\
        (card[0][i] == 0 and card[1][i] == 0 and card[2][i]):
        print("Yes")
        exit()
if  (card[0][0] == 0 and card[1][1] == 0 and card[2][2]) or\
    (card[0][2] == 0 and card[1][1] == 0 and card[2][0]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a1 = na()
a2 = na()
a3 = na()

A = a1+a2+a3
C = [0,0,0,0,0,0,0,0,0]

n = ni()

for i in range(n):
    b = ni()
    if b in A:
        C[A.index(b)] = 1
    if sum(C[0:2]) == 3 or sum(C[3:5])==3 or sum(C[6:8]) == 3 or sum(C[::4])==3 or sum(C[2::2])==3:
        print('Yes')
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []
s = 0
 
for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        if k >= 1: 
          total.append(s + j)
        else:
          total.append(k + j)
    s = s + 3
if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and 7 and 8) in total) or ((0 and 3 and 6) in total) or ((1 and 4 and 7) in total) or ((2 and 5 and 8) in total) or ((0 and 4 and 8) in total) or ((2 and 4 and 6) in total):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []
s = 0
 
for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        if k > 1: 
          total.append(s + j)
        else:
          total.append(k + j)
    s = s + 3
if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and 7 and 8) in total) or ((0 and 3 and 6) in total) or ((1 and 4 and 7) in total) or ((2 and 5 and 8) in total) or ((0 and 4 and 8) in total) or ((2 and 4 and 6) in total):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
x = input()
y = input()
z = input()
xa = x.split(" ")
ya = y.split(" ")
za = z.split(" ")
A = np.array([xa,ya,za])
N = int(input())
b =[]
C = np.array([["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"]])
for i in range(1,N+1):
    b.append(input())
for m in range(0,3):
    for n in range(0,3):
        if A[m, n] in b:
            C[m,n] = "Maru"
tate = str(np.count_nonzero(C == 'Maru', axis=0))

yoko = str(np.count_nonzero(C == 'Maru', axis=1))

if "3" in tate or "3" in yoko:
    print('Yes')
elif C[0,0] == "Maru" and C[1,1] == "Maru" and C[2,2] == "Maru":
    print("Yes")
elif C[0,2] == "Maru" and C[1,1] == "Maru" and C[2,0] == "Maru":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def checkBingo(bList):
    ret = "No"
    for i in range(3):
        for j in range(3):
            if bList[i][j] != -1:
                break
            ret = "Yes"
    for i in range(3):
        for j in range(3):
            if bList[j][i] != -1:
                break
            ret = "Yes"
    for i in range(3):
        if bList[i][i] != -1:
            break
        ret = "Yes"
    for i in range(3):
        if bList[i][2-i] != -1:
            break
        ret = "Yes"
    return ret

def deleteNumber(bList, number):
    for i in range(3):
        for j in range(3):
            if bList[i][j] == number:
                bList[i][j] = -1

raw1 = map(int, input().split())
raw2 = map(int, input().split())
raw3 = map(int, input().split())
bingo = [list(raw1), list(raw2), list(raw3)]

n = int(input())
for i in range(n):
    number = int(input())
    deleteNumber(bingo, number)

print("{}".format(checkBingo(bingo)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [input().split() for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
total = []
s = 0
 
for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        if k < 1: 
          total.append(s + j)
        else:
          total.append(k + j)
    s = s + 3
if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and 7 and 8) in total) or ((0 and 3 and 6) in total) or ((1 and 4 and 7) in total) or ((2 and 5 and 8) in total) or ((0 and 4 and 8) in total) or ((2 and 4 and 6) in total):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A = [[0]*3 for _ in range(3)]
bingo = [[False]*3 for _ in range(3)]
for i in range(3):
    ls = list(map(int, input().split()))
    for j in range(3):
        A[i][j] = ls[j]

N = int(input())
for i in range(N):
    a = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == a:
                bingo[j][k] = True

for i in range(3):
    for j in range(3):
        if A[i][j] == True:
            continue
        if j == 2:
            print("Yes")
            exit()

for j in range(3):
    for i in range(3):
        if A[i][j] == True:
            continue
        if i == 2:
            print("Yes")        
            exit()   
if A[0][0] == True and A[1][1] == True and A[2][2] == True:
    print("Yes")
    exit()

if A[0][2] == True and A[1][1] == True and A[2][0] == True:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
card = [input().split() for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == num:
                card[i][j] = 0
                break
for i in range(3):
    if  (card[0][i] != 0 and card[1][i] != 0 and card[2][i]) or\
        (card[0][i] != 0 and card[1][i] != 0 and card[2][i]) or\
        (card[0][i] != 0 and card[1][i] != 0 and card[2][i]):
        print("Yes")
        exit()
if (card[0][0] != 0 and card[1][1] != 0 and card[2][2]) or\
    (card[0][2] != 0 and card[1][1] != 0 and card[2][0]):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

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

Bingo_index=[]
master =[]
# 二次元リスト
Row = 3
List=[[int(j) for j in input().split()] for i in range(Row)]
# 二次元リストを一次元リストに
dim_List=list(itertools.chain.from_iterable(List))
# print(dim_List)
# ビンゴ表作成終わり

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

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

# Bingo_indexの中身にとanswer1~7の組み合わせがあるかどうか調べる
# 全部のアンサーとandをとってどれかの長さが3の奴があればyes出力や
master.append(answer1)
master.append(answer2)
master.append(answer3)
master.append(answer4)
master.append(answer5)
master.append(answer6)
master.append(answer7)
# print(master)
# 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

A = np.array([input().split() for i in range(3)])
n = int(input())
l = [int(input()) for i in range(n)]

B = np.ravel(A)

Submission status: Wrong Answer

Solution code:
c = [input().split() for l in range(3)]
N = int(input())
b = [int(input()) for l in range(N)]
a = [[],[],[]]
a[0] = [int(s) for s in c[0]]
a[1] = [int(s) for s in c[1]] 
a[2] = [int(s) for s in c[2]]


if a[0][0] in b:
  if (a[0][1] in b)and(a[0][2] in b):
      print("Yes")
  elif (a[1][0] in b)and(a[2][0] in b):
      print("Yes")
  elif (a[1][1] in b)and(a[2][2] in b):
      print("Yes")
elif a[0][1] in b:
  if (a[1][1] in b)and(a[2][1] in b):
      print("Yes")
elif a[0][2] in b:
  if (a[1][2] in b)and(a[2][2] in b):
      print("Yes")
  elif (a[1][1] in b)and(a[2][0] in b):
      print("Yes")
elif a[1][0] in b:
  if (a[1][1] in b)and(a[1][2] in b):
      print("Yes")
elif a[2][0] in b:
  if (a[2][1] in b)and(a[2][2] in b):
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
A=[]
B=np.zeros(9)
C=[]
for i in range(3):
  A+=map(int,input().split())
N=int(input())
#print(A)
for i in range(N):
  C.append(int(input()))
for i in C:
  if (i in A)==1:
    B[A.index(i)]=1
#print(B)
abc=0
for i in range(3):
  if B[0+i*3]==B[1+i*3]==B[2+i*3]==1:
    abc=1

for i in range(3):
  if B[0+i]==B[3+i]==B[6+i]==1:
    abc+1
if B[0]==B[4]==B[8]==1:
  abc=1
if B[2]==B[4]==B[6]==1:
  abc=1
if abc==0:
  print("No")
else:
  print("Yes")

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("Input",Input)
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')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
li=[[]]*8
for i in range(3):
    li[i] = list(map(int,input().split()))
n=int(input())
bs=[int(input()) for i in range(n)]
for i in range(3,6):
    li[i]=[li[i-3][0],li[i-3][1],li[i-3][2]]
li[6]=[li[0][0],li[1][1],li[2][2]]
li[7]=[li[0][2],li[1][1],li[2][0]]
t=0
for i in range(8):
    for j in range(n):
        if bs[j] in li[i]:
          li[i].remove(bs[j])
    if li[i]:
        continue
    else:
        t+=1
        break
if t>0:
    print('Yes')
else:
    print('No')

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:
NA=input().split()
NB=input().split()
NC=input().split()
N=int(input())
A=[input() for i in range(N)]
LA=[]
LB=[]
LC=[]
X=0
for x in NA:
	for j in range(N):
		if x==str(A[j]):
			y="101"
			break
		else:
			y=x
	LA.append(y)
for x in NB:
	for j in range(N):
		if x==str(A[j]):
			y="101"
			break
		else:
			y=x
	LB.append(y)
for x in NC:
	for j in range(N):
		if x==str(A[j]):
			y="101"
			break
		else:
			y=x
	LC.append(y)
 # NB=NB.replace(str(A[j]),"100")
  #NC=NC.replace(str(A[j]),"100")
  
  
card=[LA,LB,LC]

if  (card[0][0]=="101" and card[1][1]=="101" and card[2][2]=="101") :
  print("Yes")
  X+=1
if  (card[0][2]=="101" and card[1][1]=="101" and card[2][0]=="101") :
  print("Yes")
  X+=1
if  (card[0][0]=="101" and card[0][1]=="101" and card[0][2]=="101") :
  print("Yes")
  X+=1
if  (card[1][0]=="101" and card[1][1]=="101" and card[1][2]=="101") :
  print("Yes")
  X+=1
if  (card[2][0]=="101" and card[2][1]=="101" and card[2][2]=="101") :
  print("Yes")
  X+=1
if  (card[0][0]=="101" and card[1][0]=="101" and card[2][0]=="101") :
  print("Yes")
  X+=1
if  (card[1][0]=="101" and card[1][1]=="101" and card[2][1]=="101") :
  print("Yes")
  X+=1
if  (card[2][0]=="101" and card[2][1]=="101" and card[2][2]=="101") :
  print("Yes")
  X+=1
if X==0:
  print("No")

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[i]).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][0]:
        return"yes"
    return "No"
 
for k in num:
    result=input_b(xy,k[0],result)
 
print(check_result(result))

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 any((all(b[0][:]) , all(b[1][:]) , all(b[2][:])\
, all(b[:][0]) , all(b[:][1]) , all(b[:][2])\
, all((b[0][0],b[1][1],b[2][2])) , all((b[0][2],b[1][1],b[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')
     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()