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:

def check_bingo(hyou):
    bingo_list = [[[0,0],[0,1],[0,2]],\
                [[1,0],[1,1],[1,2]],\
                [[2,0],[2,1],[2,2]],\
                [[0,0],[1,1],[2,2]],\
                [[0,2],[1,1],[2,0]],\
                [[0,0],[1,0],[2,0]],\
                [[0,1],[1,1],[2,1]],\
                [[0,2],[1,2],[2,2]]\
                ]
    for bingo in bingo_list:
        if hyou[bingo[0][0]][bingo[0][0]] == True and hyou[bingo[1][0]][bingo[1][1]] == True and hyou[bingo[2][0]][bingo[2][1]] == True:
            return True
    return False

l = [[int(i) for i in input().split()] for M in range(3)]
N = int(input())
results = [int(input()) for i in range(N)]

hyou = [[False]*3]*3

ans = "No"
for result in results:
    for ix,i in enumerate(l):
        for j in i:
            if result in i:
                hyou[ix][i.index(j)] = True
    if check_bingo(hyou) == True:
        ans = "Yes"
print(ans)

Submission status: Wrong Answer

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


n = int(input())

bs = []
for i in range(n):
    bs.append(int(input()))



ans1 = False
for i in range(3):
    a = True
    for j in range(3):
        if ls[i][j] in bs:
            continue
        else:
            a = False
    if a == True:
        ans1 = True
        break
    else:
        continue

ans2 = False
if (ls[0][0] in bs) and (ls[1][1] in bs) and (ls[2][2] in bs):
    ans2 = True

ans3 = False
if (ls[2][0] in bs) and (ls[1][1] in bs) and (ls[0][2] in bs):
    ans3 = True


if (ans1 == True) or (ans2 == True) or (ans3 == True):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
L = []
bingo = set()
Numbers = []
testor = 0
for i in range(3):
  a,b,c = map(int,input().split())
  L.append((a,b,c)) #00 10 20/ 01 11 21/ 02 12 22/00 11 22/ 20 11 02/
N = int(input())
for i in range(3):
  a = L[0][i] 
  b = L[1][i]
  c = L[2][i]
  L.append((a,b,c))
a = L[0][0]
b = L[1][1]
c = L[2][2]
L.append((a,b,c))
a = L[2][0] 
b = L[1][1]
c = L[0][2]
L.append((a,b,c))
print(L)
for i in range(N):
  Numbers.append(int(input()))
for i in range(8): #8 bingos pattern
  bingo = L[i]
  for k in range(N):
    if Numbers[k] in bingo:
      testor += 1
    if testor == 3:
        print('Yes')
        sys.exit(0)
  testor = 0
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 = []

for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        total.append(k + j)
      
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,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = []
for i in range(n):
    A.append(int(input()))
if (a in A) and (b in A) and (c in A):
    print("Yes")
elif d in A and e in A and f in A:
    print("Yes")
elif g in A and h in A and i in A:
    print("Yes")
elif a in A and d in A and g in A:
    print("Yes")
elif b in A and e in A and h in A:
    print("Yes")
elif c in A and f in A and i in A:
    print("Yes")
elif a in A and e in A and i in A:
    print("Yes")
elif c in A and e in A and g in A:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def check(A,b):
    for raw in range(3):
        for colomn in range(3):
            if A[raw][colomn] == b:
                A[raw][colomn] = -1
                return
    return

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
is_bingo = 'No'
for _ in range(N):
    b = int(input())
    check(A,b)

print(A)
for raw in range(3):
    if A[raw][0] + A[raw][1] + A[raw][2] == -3:
        is_bingo = 'Yes'

for colomn in range(3):
    if A[0][colomn] + A[1][colomn] + A[2][colomn] == -3:
        is_bingo = 'Yes'

if A[0][0] + A[1][1] + A[2][2] == -3:
    is_bingo = 'Yes'
if A[0][2] + A[1][1] + A[2][0] == -3:
    is_bingo = 'Yes'

print(is_bingo)

Submission status: Wrong Answer

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

  N_list = []
  N = int(input())
  for i in range(N):
    N_list.append(int(input()))
  
  for i in N_list:
    for j in range(3):
      for k in range(3):
        if A[j][k] == i:
          A[j][k] = 0
        else:
          pass

  flag = False

  for i in range(3):
    if sum(A[i]) == 0:
      flag = True

  sum_1 = 0 
  for i in range(3):
    sum_1 += A[i][0]
  if sum_1 == 0:
    flag == True

  sum_2 = 0 
  for i in range(3):
    sum_2 += A[i][1]
  if sum_2 == 0:
    flag == True  

  sum_3 = 0 
  for i in range(3):
    sum_3 += A[i][2]
  if sum_3 == 0:
    flag == True

  naname1 = A[0][0] + A[1][1] + A[2][2]
  if naname1 == 0:
    flag = True

  naname2 = A[0][2] + A[1][1] + A[2][0]
  if naname2 == 0:
    flag = True
  
  if flag == True:
    print('Yes')
  else:
    print('No')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
b=[]
c=[0]*9
for i in range(3):
  a=input().split()
  b.append(int(a[0]))
  b.append(int(a[1]))
  b.append(int(a[2]))
N=int(input())
for i in range(N):
  e=int(input())
  for j in range(9):
    if(e==b[j]):
      c[j]=1
if(c[0]==c[1]==c[2]):
  print('Yes')
elif(c[3]==c[4]==c[5]):
  print('Yes')
elif(c[6]==c[7]==c[8]):
  print('Yes')
elif(c[0]==c[4]==c[8]):
  print('Yes')
elif(c[2]==c[4]==c[6]):
  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 = [int(input()) for _ in range(N)]

cnt1 = 0
for i in A1:
    if i in b:
        cnt1 += 1
    if cnt1 == 3:
        flag1 = 1
    else:
        flag1 = 0

cnt2 = 0
for i in A2:
    if i in b:
        cnt2 += 1
    if cnt2 == 3:
        flag2 = 1
    else:
        flag2 = 0

cnt3 = 0
for i in A3:
    if i in b:
        cnt3 += 1
    if cnt3 == 3:
        flag3 = 1
    else:
        flag3 = 0

cnt4 = 0
for i in [A1[0], A2[1], A3[2]]:
    if i in b:
        cnt4 += 1
    if cnt4 == 3:
        flag4 = 1
    else:
        flag4 = 0

cnt5 = 0
for i in [A1[2], A2[1], A3[0]]:
    if i in b:
        cnt5 += 1
    if cnt5 == 3:
        flag5 = 1
    else:
        flag5 = 0

cnt6 = 0
for i in [A1[0], A2[0], A3[0]]:
    if i in b:
        cnt6 += 1
    if cnt6 == 3:
        flag6 = 1
    else:
        flag6 = 0

cnt7 = 0
for i in [A1[1], A2[1], A3[1]]:
    if i in b:
        cnt7 += 1
    if cnt7 == 3:
        flag7 = 1
    else:
        flag7 = 0

cnt8 = 0
for i in [A1[2], A2[2], A3[2]]:
    if i in b:
        cnt8 += 1
    if cnt8 == 3:
        flag8 = 1
    else:
        flag8 = 0

if flag1 == 1 or flag2 == 1 or flag3 == 3 or flag4 == 1 or flag5 == 1 or flag6 == 1 or flag7 == 1 or flag8 == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def output(A, b): 
    BW = [0,0,0]
    for i in range(len(A)):
        for j in range(len(b)):
            if(A[i] == b[j]):
                BW[i] = 1
                break
            else:
                continue
    return BW

A0 = list(map(int, input().split()))
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
N = int(input())
b = [0]*N
for i in range(N):
    b[i] = int(input())

x = output(A0, b)
y = output(A1, b)
z = output(A2, b)

ans = 0
if(x.count(3) or y.count(3) or z.count(3)):
    ans = 1
for i in range(3):
    if(x[i]==1 and y[i]==1 and z[i]==1):
        ans = 1
        break
if(ans==0):
    if(x[0]==1 and y[1]==1 and z[2]==1):
        ans = 1
    elif(x[2]==1 and y[1]==1 and z[0]==1):
        ans = 1

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

Submission status: Wrong Answer

Solution code:
A_list = []

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

for i in range(3):
  a, b, c = map(int, input().split())
  A_list.append(a)
  A_list.append(b)
  A_list.append(c)

N = int(input())
flag=True

for i in range(N):
  num = int(input())

  tmp = my_index(A_list, num)
  if tmp != False or tmp == 0:
    A_list[tmp] = -1
  
  if ((A_list[0] == A_list[3]) and (A_list[0] == A_list[6]) and (A_list[3] == A_list[6])) or \
     ((A_list[1] == A_list[4]) and (A_list[1] == A_list[7]) and (A_list[4] == A_list[7])) or \
     ((A_list[2] == A_list[5]) and (A_list[2] == A_list[8]) and (A_list[5] == A_list[8])) or \
     ((A_list[0] == A_list[4]) and (A_list[0] == A_list[8]) and (A_list[4] == A_list[8])) or \
     ((A_list[2] == A_list[4]) and (A_list[2] == A_list[6]) and (A_list[4] == A_list[6])) or \
     ((A_list[0] == A_list[1]) and (A_list[0] == A_list[2]) and (A_list[1] == A_list[2])) or \
     ((A_list[3] == A_list[4]) and (A_list[3] == A_list[5]) and (A_list[4] == A_list[5])) or \
     ((A_list[6] == A_list[7]) and (A_list[6] == A_list[8]) and (A_list[7] == A_list[8])):
    print("Yes")
    flag=False
    break

if flag:
  print("No")

Submission status: Wrong Answer

Solution code:
def common_member(a, b): 
    a_set = set(a) 
    b_set = set(b) 
    if (a_set & b_set): 
        return "Yes"
    else: 
        return "No"

L = list(map(int,input().split()))
L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))
LL = L + L1 + L2
N = int(input())
M = []
for i in range(N):
    ML = input()
    M.append(int(ML))
print(common_member(M,LL))

Submission status: Wrong Answer

Solution code:
import numpy as np
A = [list(map(int, input().split())) for i in range(0,3)]
N = int(input())
b_list =list([int(input()) for i in range(0,N)])
count = np.zeros((3,3))
for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b_list:
            count[i][j] = count[i][j] + 1
if (count.sum(axis=1) % 3 ==0).any():
    print('Yes')
elif (count.sum(axis=0) % 3 ==0).any():
    print('Yes')
elif count[0][0] + count[1][1] + count[2][2]:
    print('Yes')
elif count[2][0] + count[1][1] + count[0][2]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# n = int(input())
# H = list(map(int,input().split()))


A1 = list(input().split())
A2 = list(input().split())
A3 = list(input().split())
n = int(input())

if n <= 2:
    print("No")
    exit()

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

for i in B:
    if i in A1:
        A1[A1.index(i)] = "#"
    if i in A2:
        A2[A2.index(i)] = "#"
    if i in A3:
        A3[A3.index(i)] = "#"


flag = 0
for i in range(3):
    if A1[i] == "#":
        flag += 1
    if A2[i] == "#":
        flag += 1
    if A3[i] == "#":
        flag += 1
    if flag != 3:
        flag = 0
if flag == 3:
    print("Yes")
    exit()

if A1[0] == "#" and A1[1] == "#" and A1[2] == "#":
    print("Yes")
    exit()

if A2[0] == "#" and A2[1] == "#" and A2[2] == "#":
    print("Yes")
    exit()

if A3[0] == "#" and A3[1] == "#" and A3[2] == "#":
    print("Yes")
    exit()

if A1[0] == "#" and A2[1] == "#" and A3[2] == "#":
    print("Yes")
    exit()

if A3[0] == "#" and A2[1] == "#" and A1[2] == "#":
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
l = []
flag = 0
for i in range(3):
  l.append(list(input().split()))
n = int(input())
for i in range(n):
  a = int(input())
  for j in range(3):
    for m in l[j]:
      if m == a:
        l[j][l.index(m)] = 0
for i in range(3):
  if not any(l[i]):
    flag = 1
if l[0][0] == l[1][0] == l[2][0] or l[0][1] == l[1][1] == l[2][1] or l[0][2] == l[1][2] == l[2][2]:
  flag = 1
if l[0][0] == l[1][1] == l[2][2] or l[0][2] == l[1][1] == l[2][0]:
  flag = 1
if flag == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A_list = []
for i in range(3):
    A = list(map(int, input().split()))
    A_list.append(A)
N = int(input())
for i in range(N):
    B = int(input())
    for j in range(3):
        for k in range(3):
            if A_list[j][k]==B:
                A_list[j][k] = -1
flag = True
for i in range(3):
    for j in range(3):
        if A_list[i][j]!=-1:
            flag = False
            break
if flag:
    print("Yes")
    exit()
else:
    flag = True
for i in range(3):
    for j in range(3):
        if A_list[j][i]!=-1:
            flag = False
            break
if flag:
    print("Yes")
    exit()
else:
    flag = True
for i in range(3):
    if A_list[i][i]!=-1:
        flag = False
        break
if flag:
    print("Yes")
    exit()
else:
    flag = True
for i in range(3):
    if A_list[i][2-i]!=-1:
        flag = False
        break
if flag:
    print("Yes")
    exit()
else:
    print("No")

Submission status: Wrong Answer

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

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

import numpy as np
table = np.zeros(shape=(3,3))

for _ in range(N):
    b = int(input())
    if b == A11:
        table[0][0] = 1
    elif b == A12:
        table[0][1] = 1
    elif b == A13:
        table[0][2] = 1
    elif b == A21:
        table[1][0] = 1
    elif b == A22:
        table[1][1] = 1
    elif b == A23:
        table[1][2] = 1
    elif b == A31:
        table[2][0] = 1
    elif b == A32:
        table[2][1] = 1
    elif b == A33:
        table[2][2] = 1
        
        
if sum(table[0][:]) == 3 or sum(table[1][:]) == 3 or sum(table[2][:]) == 3 or sum(table[:][0]) == 3 or sum(table[:][1]) == 3 or sum(table[:][2]) == 3 or (table[0][0] + table[1][1] + table[2][2]) == 3 or (table[2][0]+table[1][1] + table[0][2]) == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = [int(j) for i in range(3) for j in input().split(' ')]
n = int(input())
nn = [int(input()) for i in range(n)]

for ni in nn:
  if ni in a:
    a[a.index(ni)] = 0

    
judge = "Yes"
if a[4]!=0:
  if a[2]!=0 and a[6]!=0:
    judge = "No"
else:
  if a[2]!=0 and a[6]!=0 and a[1]!=0 and a[7]!=0:
    judge = "No"

print(judge)

Submission status: Wrong Answer

Solution code:
#N行複数列の文字列複数を行列として入力
table = [input().split() for l in range(3)]
N = int(input())
array = [input() for i in range(N)]
bingo = ""

for k in range(3):
    for j in range(3):
        if table[k][j] in array:
            table[k][j] = 0

        table[k][j] = int(table[k][j])

for l in range(3):
    if table[l][0] + table[l][1] + table[l][2] == 0:
        bingo = "Yes"

for l in range(3):
    if table[0][l] + table[0][l] + table[0][l] == 0:
        bingo = "Yes"
if table[0][0] + table[1][1] + table[2][2] == 0 or table[2][0] + table[1][1] + table[2][0] ==0:
        bingo = "Yes"

if bingo == "":
    bingo = "No"

print(bingo)

Submission status: Wrong Answer

Solution code:
import sys
L = []
bingo = set()
Numbers = []
testor = 0
for i in range(3):
  a,b,c = map(int,input().split())
  L.append((a,b,c)) #00 10 20/ 01 11 21/ 02 12 22/00 11 22/ 20 11 02/
N = int(input())
for i in range(3):
  a = L[0][i] 
  b = L[1][i]
  c = L[2][i]
  L.append((a,b,c))
a = L[0][0]
b = L[1][1]
c = L[2][2]
L.append((a,b,c))
a = L[2][0] 
b = L[1][1]
c = L[0][2]
L.append((a,b,c))
for i in range(N):
  Numbers.append(int(input()))
for i in range(7): #8 bingos pattern
  bingo = L[i]
  for k in range(N):
    if Numbers[k] in bingo:
      testor += 1
    if testor == 3:
        print('Yes')
        sys.exit(0)
  testor = 0
print('No')

Submission status: Wrong Answer

Solution code:
bingo = []
checklists = []
for i in range(3):
  lists = list(map(int,input().split()))
  bingo.append(lists)
num = int(input())
for i in range(num):
  checklists.append(int(input()))
for i in range(3):
  for j in range(3):
    if bingo[i][j] in checklists:
        bingo[i][j] = 0
result = "No"
for i in range(3):
  for k in range(3):
    yoko = 0
    tate = 0
    if bingo[i][k] == 0:
      yoko += 0
    elif bingo[k][i] == 0:
      tate += 0
  if (yoko or tate) == 3:
    result = "Yes"
naname1 = 0
naname2 = 0
for i in range(3):
  if bingo[i][i] == 0:
    naname1 += 1
  elif bingo[i][-i] == 0:
    naname2 += 1
if (naname1 or naname2) == 3:
  result = "Yes"
print(result)

Submission status: Wrong Answer

Solution code:
import sys
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
ans_flag = True
ans_flag2 = True
ans = [[False, False, False], [False, False, False], [False, False, False]]

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

for i in range(3):
    if ans[0][i] and ans[1][i] and ans[2][i]:
        print('Yes')
        sys.exit()
    if ans[i][0] and ans[i][1] and ans[i][2]:
        print('Yes')
        sys.exit()
    if not ans[i][i]:
        ans_flag = False
    if not ans[i][2-i]:
        ans_flag2 = False

print(ans)

if ans_flag or ans_flag2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a=[0,0,0]
for i in range (3):
  a[i] = list(map(int,input().split()))
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:
        a[j][k] = 0

done = 0
for i in range(3):
  if a[i][0] == a[i][1] == a[i][2] == 0 or a[0][i] == a[1][i] == a[2][i] == 0 :
    done = 1
    print('Yes')

if done == 0 and (a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0) :
  print('Yes')
  done = 1

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

Submission status: Wrong Answer

Solution code:
def checkbingo(map_):
  for i in range(3):
    if map_[i][0] * map_[i][1] * map_[i][2] == 1:
      return True
    if map_[0][i] * map_[0][i] * map_[0][i] == 1:
      return True
  if map_[0][0] * map_[1][1] * map_[2][2] == 1:
    return True
  if map_[0][2] * map_[1][1] * map_[2][0] == 1:
    return True
  return False 

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1,A2,A3]
bingomap = [[0,0,0],[0,0,0],[0,0,0]]
N = int(input())
b = list()
ret = 'No'
for i in range(N):
  b.append(int(input()))
for i in range(N):
  for j in range(3):
    if b[i] in A[j]:
      bingomap[j][A[j].index(b[i])] = 1
      break
  if i >= 2 :
    if checkbingo(bingomap) == True:
      ret = 'Yes'
      break
print(ret)

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 = []

for i in range(n):
  for k in range(3):
    for j in range(3):
      if b[i] == int(a[k][j]):
        total.append(k + j)
        break
      
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
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
a = np.array(a)
for i in range(n):
    a[np.where(a == b[i])] = bool(b[i] in a)
def check(i,j):
    if i > 0 and i < 3 and j > 0 and j < 3:
        if a[i][j] == 1:
            return True
    return False
        
for i in range(3):
    for j in range(3):
        if a[i][j] == 1:
            if (check(i+1,j) and check(i+2,j)) or (check(i,j+1) and check(i,j+2)) or (check(i+1,j+1) and check(i+2,j+2)) or (check(i-1,j-1) and check(i-2,j-2)):
                print('Yes')
                break
    else:
        continue
    break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A=[]
for i in range(0,3):
    k=list(map(int,input().split(' ')))
    A.append(k)
n=int(input())
b=[]
for i in range(0,n):
    b.append(int(input()))
for i in range(0,3):
    if (A[1][i] and A[2][i] and A[0][i]) in b:
        print('Yes')
        quit()
    if (A[i][1] and A[i][2] and A[i][0]) in b:
        print('Yes')
        quit()
if (A[0][0] and A[2][2] and A[1][1]) in b:
    print('Yes')
    quit()
if (A[0][2] and A[2][0] and A[1][1]) in b:
    print('Yes')
    quit()
print('No')

Submission status: Wrong Answer

Solution code:
A = [[0] * 3] * 3

for i in range(3):
    a, b, c = map(int, input().split())
    A[i][0], A[i][1], A[i][2] = a, b, c

N = int(input())
B = [0] * N
for i in range(N):
    B[i] = int(input())

# input ここまで
import itertools
def flatten_list(l):
    return list(itertools.chain.from_iterable(l))

mark_list = [False] * 9

flatten_A = flatten_list(A)
for b in B:
    if not b in flatten_A: continue
    # 選ばれた数が自分のビンゴに含まれている
    for i in range(9):
        if flatten_A[i] == b:
            mark_list[i] = True

"""
[0, 1, 2], [3, 4, 5], [6, 7, 8]
[0, 3, 6], [1, 4, 7], [2, 5, 8]
[0, 4, 8], [2, 4, 6]
"""
def judge_bingo(l):
    yes = "Yes"
    no = "No"
    if l.count(1) < 3:
        return no
    if l[0] == 1:
        if l[1] and l[2]:
            return yes
        if l[3] and l[6]:
            return yes
        if l[4] and l[8]:
            return yes
    if l[3] and l[4] and l[5]:
        return yes
    if l[1] and l[4] and l[7]:
        return yes
    if l[2]:
        if l[4] and l[6]: return yes
        if l[5] and l[8]: return yes
    if l[6] and l[7] and l[8]:
        return yes
    return no
        

ans = judge_bingo(mark_list)
print(ans)

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_lst = [int(input()) for _ in range(n)]
a_lst = a1 + a2 + a3

for i in range(len(b_lst)):
    if b_lst[i] in a_lst:
        a_lst[a_lst.index(b_lst[i])] = 0

for i in range(3):
    if a_lst[i] == a_lst[i+3] == a_lst[i+6] == 0:
        print("Yes")
        break
    elif a_lst[3*i] == a_lst[3*i+1] == a_lst[3*i+2] == 0:
        print("Yes")
        break
    elif a_lst[2] == a_lst[4] == a_lst[6] == 0 or a_lst[0] == a_lst[4] == a_lst[8] == 0:
        print("Yes")
        break
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
def main():
    bingo = [input().split(" ") for _ in range(3)]
    n = int(input())
    line = [[], [], []]
    cross1 = []
    cross2 = []
    for _ in range(n):
        num = input()
        found = False
        for i in range(3):
            for j in range(3):
                if bingo[i][j] == num:
                    found = True
                    if i == j:
                        cross1.append((i, j))
                    if i == 0 and j == 2:
                        cross2.append((i, j))
                    if i == 2 and j == 0:
                        cross2.append((i, j))
                    if i == 1 and j == 1:
                        cross2.append((i, j))
                    line[i].append((i, j))
                    continue
            if found:
                continue
    for l in line:
        if len(l) == 3:
            print("Yes")
            return
    if len(cross1) == 3:
        print("Yes")
    elif len(cross2) == 3:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = []
b = []
s = set()
for i in range(3):
    ai = list(map(int, input().split()))
    a.append(ai)
    s.update(ai[0:2])
n = int(input())
for i in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = 0

chk = 0
for i in range(3):
    for j in range(3):
        if a[i][j] == 0 and chk == 0:
            print("Yes")
            chk = 1
            break
if chk == 0:
    if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        print("Yes")
    elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
def bingo(A, B):
  for i in range(3):
    if A[i][0] == "o" and A[i][1] == "o" and A[i][2] == "o":
      return True
    elif A[0][i] == "o" and A[1][i] == "o" and A[2][i] == "o":
      return True
    
  if A[0][0] == "o" and A[1][1] == "o" and A[2][2] == "o":
    return True
  elif A[0][2] == "o" and A[1][1] == "o" and A[2][0] == "o":
    return True
    
  return False

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

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

if bingo(A, B):
  print("YES")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def main():
    A = [list(map(int,input().split(" "))) for i in range(3)]
    N = int(input())
    b_list = [int(input()) for _ in range(N)]

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

    flag = False
    for i in range(3):
        for j in range(3):
            if(i+1<3 and i+2<3 and j+1 < 3 and j+2 < 3):
                if(A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
                if(A[i][j] == 0 and A[i-1][j-1] == 0 and A[i-2][j-2] == 0):
                    flag = True
                    break
        if(flag):
            break

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
X = []
Y = []
Z = []
for i in range(3):
    x, y, z = map(str, input().split())
    X.append(x)
    Y.append(y)
    Z.append(z)
N = int(input())

b = map(str, [input() for i in range(N)])

for x in sorted(b, reverse=True):
    X = [s.replace(x, 'OK') for s in X]
    Y = [s.replace(x, 'OK') for s in Y]
    Z = [s.replace(x, 'OK') for s in Z]

if ('OK' in X[0] and 'OK' in X[1] and 'OK' in X[2]
    or 'OK' in Y[0] and 'OK' in Y[1] and 'OK' in Y[2]
    or 'OK' in Z[0] and 'OK' in Z[1] and 'OK' in Z[2]
    or 'OK' in X[0] and 'OK' in Y[0] and 'OK' in Z[0]
    or 'OK' in X[1] and 'OK' in Y[1] and 'OK' in Z[1]
    or 'OK' in X[2] and 'OK' in Y[2] and 'OK' in Z[2]
    or 'OK' in X[0] and 'OK' in Y[1] and 'OK' in Z[2]
    or 'OK' in X[2] and 'OK' in Y[1] and 'OK' in Z[0]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
line1 = input().split(" ")
line2 = input().split(" ")
line3 = input().split(" ")

result1 = []
result2 = []
result3 = []

for i in range(3):
  result1.append("0")
  result2.append("0")
  result3.append("0")

call_sum = int(input())

for j in range(call_sum):
  call_num = int(input())
  for i in range(3):
    if call_num == int(line1[i]):
      result1[i] = "1"
      break
    if call_num == int(line2[i]):
      result2[i] = "1"
      break
    if call_num == int(line3[i]):
      result3[i] = "1"
      break
while(1):
  if result1[0] == result1[1] == result1[2] == "1" or result2[0] == result2[1] == result2[2] == "1" or result3[0] == result3[1] == result3[2] == "1":
    print("Yes")
    break
  elif result1[0] == result2[1] == result3[2] == "1" or result1[2] == result2[1] == result3[0] == "1":
    print("Yes")
    break
  for j in range(3):
    end_flg = False
    if result1[i] == result2[i] == result3[i] == "1":
      print("Yes")
      end_flg = True
    if end_flg:
      break
  print("No")
  break

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))

loopflag = False
if N >= 3:
    for i in range(len(result)):
        for j in range(len(result)):
            for k in range(len(result)):
                if (i==j or j==k or k==i):
                    break
                if((result[i] + result[j] + result[k]) % 3 == 0):
                    loopflag = True
    if loopflag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:

def check_bingo(hyou):
    bingo_list = [[[0,0],[0,1],[0,2]],\
                [[1,0],[1,1],[1,2]],\
                [[2,0],[2,1],[2,2]],\
                [[0,0],[1,1],[2,2]],\
                [[2,0],[1,1],[2,0]],\
                [[0,0],[1,0],[1,0]],\
                [[0,1],[1,1],[2,1]],\
                [[0,2],[1,2],[2,2]]\
                ]
    for bingo in bingo_list:
        if hyou[bingo[0][0]][bingo[0][0]] == True and hyou[bingo[1][0]][bingo[1][1]] == True and hyou[bingo[2][0]][bingo[2][1]] == True:
            return True
    return False

l = [[int(i) for i in input().split()] for M in range(3)]
N = int(input())
results = [int(input()) for i in range(N)]

hyou = [[False]*3]*3

ans = "No"
for result in results:
    for ix,i in enumerate(l):
        for j in i:
            if result in i:
                hyou[ix][i.index(j)] = True
    if check_bingo(hyou) == True:
        ans = "Yes"
print(ans)

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

s=[]
t=[]
cross_1=0
cross_2=0

ans="No"

for i in b:
    for j in range(3):
        if i in A[j]:
            s.append(j)
            t.append(A[j].index(i))
            if j==A[j].index(i):
                cross_1+=1
                if j==1:
                    cross_2+=1
            elif j==2-A[j].index(i):
                cross_2+=1
                
for k in range(3):
    if s.count(k)==3:
        ans="Yes"
for l in range(3):
    if t.count(l)==3:
        ans=0
if cross_1==3:
    ans="Yes"
elif cross_2==3:
    ans="Yes"

print(ans)