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:
#author: dokueki



inp = []
for i in range(3):
    a = list(map(int, input().split()))
    inp.append(a)
res = []
for _ in range(int(input())):
    res.append(int(input()))
for i in range(3):
    for j in range(3):
        for k in res:
            if inp[i][j] == k:
                inp[i][j] = -1
r1, r2, r3, c1, c2, c3, d1, d2 = 0, 0, 0, 0, 0, 0, 0, 0
for i in range(3):
    if inp[i][0] == -1:
        r1 += 1
    if inp[i][1] == -1:
        r2 += 1
    if inp[i][2] == -1:
        r3 += 1
    if inp[0][i] == -1:
        c1 += 1
    if inp[1][i] == -1:
        c2 += 1
    if inp[2][i] == -1:
        c3 += 1
    if inp[i][i] == -1:
        d1 += 1
if inp[0][2] == inp[1][1] == inp[2][0] == -1:
    d2 += 3
if r1 == 3 or r2 == 3 or r3 == 3 or c1 == 3 or c2 == 3 or c3 == 3 or d1 == 3 or d2 == 3:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
import math
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a = []
for i in range(3):
  n = IL()
  for j in n:
    a.append(j)

N = I()
used = [False]*9
for _ in range(N):
  n = I()
  for i in range(9):
    if a[i] == n:
      used[i] = True

f = 0
if all(used[0:3]) or all(used[3:6]) or all(used[6:9]):
  f = 1
if (used[0] and used[3] and used[6]) or (used[1] and used[4] and used[7]) or (used[2] and used[5] and used[8]):
  f = 1
if (used[0] and used[4] and used[8]):
  f = 1
if f == 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
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()))

#print(A)
#print(B)

match = []
for A_line in A:
  match.append([(a in B) for a in A_line])

#print(match)
ans = False
# 横
for m in match:
  ans = ans or all(m)

# 縦
match_v = [[m[i] for m in match] for i in range(3)]
#print(match_v)
for m in match_v:
  ans = ans or all(m)
# 斜め
ans = ans or all([match[i][i] for i in range(3)])
ans = ans or all([match[2-i][i] for i in range(3)])

print(ans)

Submission status: Wrong Answer

Solution code:
flags = [False for i in range(9)]
rows = []
for i in range(3):
    rows += list(map(int, input().split()))
N = int(input())
for ii in range(N):
    b = int(input())
    for i in range(9):
        if b == rows[i]:
            flags[i] = True
ans = False
for r in range(3):
    # print(flags[r:r+3:1])
    if sum(flags[r:r+3:1]) == 3:
        ans = True
    # print(flags[r::3])
    if sum(flags[r::3]) == 3:
        ans = True
# print(flags[0::4])
if sum(flags[0::4]) == 3:
    ans = True
# print(flags[2:7:2])
if sum(flags[2:7:2]) == 3:
    ans = True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

N = int(input())

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

card_nums = r1 + r2 + r3

bingo_list = np.zeros((3,3))
for b in bs:
    if b in card_nums:
        index = card_nums.index(b)
        bingo_list[index//3, index%3] = 1

if (3 in bingo_list.sum(axis=1)) or (3 in bingo_list.sum(axis=0)):
    print('Yes')
elif np.diag(bingo_list).sum() == 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
nums = []

for i in range(3):
    nums.append([int(n) for n in input().split(" ")])
print(nums)

bingo_list = []

bingo_list.extend(nums)
for i in range(3):
    bingo_list.append([nums[0][i], nums[1][i], nums[2][i]])
bingo_list.append([nums[0][0], nums[1][1], nums[2][2]])
bingo_list.append([nums[2][0], nums[1][1], nums[0][2]])

print(bingo_list)

is_bingo = False
n = int(input())
for i in range(n):
    num = int(input())
    for bingo in bingo_list:
        if num in bingo:
            bingo.remove(num)
            if not bingo:
                print("Yes")
                is_bingo = True

if not is_bingo:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

N = int(input())

card = np.zeros((3, 3))
for i in range(N):
    t = int(input())
    if t in A1:
        card[A1.index(t)] = 1
    if t in A2:
        card[A2.index(t)] = 1
    if t in A3:
        card[A3.index(t)] = 1
f = False
if sum(card[0]) == 3 or sum(card[1]) or sum(card[2]):
    f = True
if card[0][0] + card[1][1] + card[2][2] == 3 or card[0][2] + card[1][1] + card[2][0]:
    f = True
s = np.sum(card, axis=1)
if s[0] == 3 or s[1] == 3 or s[2] == 3:
    f = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np
A = []
for n in range(3):
    tmp_lis = list(map(int, input().split()))
    A.append(tmp_lis)

N = int(input())

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

bool_lis = [[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:
            bool_lis[i][j] = True

arr = np.array(bool_lis)
if np.trace(arr) == 3 or (arr[0][2] + arr[1][1] + arr[2][0] == 3) or 3 in sum(arr) or 3 in sum(arr.T):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

aa = [0] * 8
for i in range(3):
    for j in range(3):
        if bingo[i][j] in b:
            aa[i] += 1
            aa[j+3] += 1
            if i == j:
                aa[-2] += 1
            if i + j == 3:
                aa[-1] += 1
if 3 in aa:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A0 = list(map(int, input().split(" ")))
A1 = list(map(int, input().split(" ")))
A2 = list(map(int, input().split(" ")))



A = [A0, A1, A2]

M = [
    [False, False, False],
    [False, False, False],
    [False, False, False],
]

N = int(input())
for _ in range(N):
    b = int(input())
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if col == b:
                M[i][j] = True

flag = False
for row in M:
    if all(row):
        flag = True

for i in range(3):
    col = []
    for j in range(3):
        col.append(M[j][i])

    if all(col):
        flag = True

dia0 = []
dia1 = []
for i in range(3):
    dia0.append(M[i][j])
    dia1.append(M[2 - i][2 - i])

if all(dia0):
    flag = True

if all(dia1):
    flag = True

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
#input = sys.stdin.buffer.readline

def inn(func=int):
    return list(map(func,input().split()))

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

a0 = inn()
a1 = inn()
a2 = inn()
a = a0+a1+a2
n = int(input())
ban = [0,0,0,0,0,0,0,0,0]
for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            ban[j] = 1

for i in range(3):
    tate = ban[i]+ban[i+3]+ban[i+6]
    yoko = ban[i]+ban[i+1]+ban[i+2]
    if tate == 3 or yoko == 3:
        print("Yes")
        exit()
if (ban[0]+ban[4]+ban[8]) == 3 or (ban[2]+ban[4]+ban[6]) == 3:
    print("Yes")
    exit()
print("No")

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

bingo=[[0]*3 for _ in range(3)]
for i in range(n):
  for ai in range(3):
    for aj in range(3):
      if A[ai][aj]==B[i]:
        bingo[ai][aj]=1
flag=False
for bi in range(3):
  if bingo[bi][0]==bingo[bi][1]==bingo[bi][2]==1: flag=True
  if bingo[0][bi]==bingo[1][bi]==bingo[1][bi]==1: flag=True
  if bingo[bi][bi]==bingo[bi][bi]==bingo[bi][bi]==1: flag=True
  if bingo[bi][-bi]==bingo[bi][bi]==bingo[-bi][bi]==1: flag=True    
if flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = []
for i in range(3):
    a.append([int(i) for i in input().split()])
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

"""
c = [a[0][0], a[0][1], a[0][2]]
d = [a[1][0], a[1][1], a[1][2]]
e = [a[2][0], a[2][1], a[2][2]]
f = [a[0][0], a[1][0], a[2][0]]
g = [a[0][1], a[1][1], a[2][1]]
h = [a[0][2], a[1][2], a[2][2]]
i = [a[0][0], a[1][1], a[2][2]]
j = [a[2][0], a[1][1], a[0][2]]
"""

tmp = []
tmp2 = 0
tmp3 = 0
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                tmp.append([j,k])
                tmp2 += j
                tmp3 += k
if len(tmp) >= 3 and (tmp2 >= 3 or tmp2 == 0) and (tmp3 >= 3 or tmp3 == 0):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

a = []
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
n = int(input())
c = [[0,0,0],[0,0,0],[0,0,0]]
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] = 1

print(c)
flag = False

for i in range(3):
    if c[0][i] + c[1][i] + c[2][i] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    if c[i][0] + c[i][1] + c[i][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    if c[i%3][0] + c[(i+1)%3][1] + c[(i+2)%3][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break

Submission status: Wrong Answer

Solution code:
import numpy as np

bingo = list()
for i in range(3):
    bingo.append(list(map(int,input().split())))
N = int(input())
number = list()
for i in range(N):
    number.append(int(input()))
   
bingo_array = np.array(bingo)
check_array = np.zeros([3,3])
for i in range(N):
    check_array[bingo_array==number[i]] = 1

row = np.count_nonzero(np.any(check_array.sum(axis=0)==3))
column = np.count_nonzero(np.any(check_array.sum(axis=0)==3))
r_naname = 0
l_naname = 0
for i in range(3):
    r_naname += check_array[i, 2-i]
    l_naname += check_array[i, i]

if row != 0 or column != 0 or r_naname == 3 or l_naname == 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
    A.append(input())
N = int(input())
for i in range(N):
    X = input()
    for j in range(3):
        A[j] = A[j].replace(X, 'X')
result = []
for i in range(3):
    result.append(A[i].split())
if (result[0][0] == result[0][1] == result[0][2]) or (result[1][0] == result[1][1] == result[1][2]) or (result[2][0] == result[2][1] == result[2][2]):
    print('Yes')
elif (result[0][0] == result[1][0] == result[2][0]) or (result[0][1] == result[1][1] == result[2][1]) or (result[0][2] == result[1][2] == result[2][2]):
    print('Yes')
elif (result[0][0] == result[1][1] == result[2][2]) or (result[0][2] == result[1][1] == result[2][0]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

print(*a,sep="\n")
ans = "No"
for i in range(3):
    if sum(a[i]) == 0:
        ans = "Yes"

for i in range(3):
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"

if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"

if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
list1 = a+b+c
bingo = 0
if list1[0]==list1[1]:
    if list1[1] == list[2]:
        bingo += 1
if list1[3]==list1[4]:
    if list1[4] == list[5]:
        bingo += 1
if list1[6]==list1[7]:
    if list1[7] == list[8]:
        bingo += 1
if list1[0]==list1[3]:
    if list1[3] == list[5]:
        bingo += 1
if list1[1]==list1[4]:
    if list1[4] == list[7]:
        bingo += 1
if list1[2]==list1[5]:
    if list1[5] == list[8]:
        bingo += 1
        

if list1[0]==list1[4]:
    if list1[4] == list[8]:
        bingo += 1
if list1[2]==list1[4]:
    if list1[4] == list[6]:
        bingo += 1

if bingo > 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
flag = False
for i in range(3):
    t,b,c = map(int,input().split())
    a.append([t,b,c])
n = int(input())
for i in range(n):
    buf = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == buf:
                a[j][k] = 0
for i in range(3):
    if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0 ):
        flag = True
for i in range(3):
    if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
        flag = True
if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0 ):
    flag = True

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    from collections import defaultdict
    A = XLMIIS(3)

    exists = defaultdict(lambda : False)

    N = II()
    for _ in range(N):
        exists[II()] = True
    

    #上横、中横、下横
    for i in range(3):
        if exists[A[i][0]] and exists[A[i][1]] and exists[A[i][2]]:
            print('Yes')
            return
    #左縦、中縦、右縦
    for i in range(3):
        if exists[A[0][i]] and exists[A[1][i]] and exists[A[0][i]]:
            print('Yes')
            return
    #ナナメ
    if exists[A[0][0]] and exists[A[1][1]] and exists[A[2][2]]:
        print('Yes')
        return
    if exists[A[0][2]] and exists[A[1][1]] and exists[A[2][0]]:
        print('Yes')
        return
    print('No')
    return 
    

if __name__ == '__main__':
    main()

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:
bingo=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
B=[int(input()) for _ in range(N)]
for i in range(3):
  for b in B:
    if bingo[i][i]==b:
      bingo[i][i]="!"
for j in range(3):
  if bingo[j][0]==bingo[j][1]==bingo[j][2]=="!":
    print("Yes")
    exit()
  if bingo[0][j]==bingo[1][j]==bingo[2][j]=="!":
    print("Yes")
    exit()
  if bingo[0][0]==bingo[1][1]==bingo[2][2]=="!":
    print("Yes")
    exit()
  if bingo[0][2]==bingo[1][1]==bingo[2][0]=="!":
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
import itertools 

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

AA = list(itertools.chain.from_iterable(A))

grid = []
N = int(input())
B = []
for i in range(N):
  b = int(input())
  if b in AA:
    grid.append(AA.index(b))
  B.append(b)

if (0 in grid and 4 in grid and 8 in grid) or (2 in grid and 4 in grid and 6 in grid):
  print("Yes")
elif(0 in grid and 1 in grid and 2 in grid) or (2 in grid and 4 in grid and 5 in grid) or (6 in grid and 7 in grid and 8 in grid):
  print("Yes")
elif(0 in grid and 3 in grid and 6 in grid) or (1 in grid and 4 in grid and 7 in grid) or (2 in grid and 5 in grid and 8 in grid):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

b = []

for i in range(n):
  b.append(int(input()))


for i in range(len(b)):
  for a_i in range(len(A[0])):
    for a_j in range(len(A[1])):
      if A[a_i][a_j] == b[i]:
        A[a_i][a_j] = 0


for i in range(len(A[0])):
  if A[0][i] != 0 and A[i][0] != 0 and A[i][i] != 0:
    print("No")
    break

  if i == 2:
    print("Yes")

Submission status: Wrong Answer

Solution code:
card = [list(map(int,input().split(' '))) for j in range(3)]
N = int(input())
called = set([int(input()) for i in range(N)])
for x,i in enumerate(card):
    for y,j in enumerate(i):
        if j in called:
            card[x][y] = 0
for i in range(3):
    if sum(card[i])==0:
        print('Yes')
        exit()
    if sum([card[i][j] for j in range(3)])==0:
        print('Yes')
        exit()
if (card[0][0]+card[1][1]+card[2][2])==0 or (card[0][2]+card[1][1]+card[2][0])==0:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
card = []
for i in range(3):
  card.append(list(map(int, input().split())))
card = np.array(card)
n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if (card[i, j] == b):
                card[i, j] = 0
flag = 0
for i in range(3):
  if (sum(card[i,:]) == 0):
    flag = 1
  if (sum(card[:,i]) == 0):
    flag = 1
if (card[0,0]+card[1,1]+card[2,2] == 0):
  flag = 1
if (card[0,2]+card[1,1]+card[2,0] == 0):
  flag = 1
if (flag == 1):
  print("yes")
else:
  print("no")

Submission status: Wrong Answer

Solution code:
a = []

b = {}

for i in range(3):
    x = map(int, input().split())
    a += x

n = int(input())

ans = [0 for i in range(9)]

for i in range(n):
    x = int(input())
    if x in a:
        index = a.index(x)
        ans[index] = 1

# print(a)
# print(ans)

flag = False

for i in range(3):
    if ans[i] + ans[i + 1] + ans[i + 2] == 3:
        flag = True
        break
    if ans[i] + ans[i + 3] + ans[i + 6] == 3:
        flag = True
        break

if ans[0] + ans[4] + ans[8] == 3:
    flag = True
elif ans[2] + ans[4] + ans[6] == 3:
    flag = True

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

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

a_ = [[0]*3 for _ in range(3)]
for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a_[j][k] = 1
                
count = 0
for i in range(3):
    count += (a_[i][0]+a_[i][1]+a_[i][2])//3
    count += (a_[0][i]+a_[1][i]+a_[2][i])//3
    
count += (a_[0][0]+a_[1][1]+a_[2][2])//3

if count > 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = [[0] * 3 for i in range(3)]

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

N = int(input())

for _ 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

ans = "No"
# yoko
for i in range(3):
    if sum(A[i]) == 0:
        ans = "Yes"

# tate
x = A[0][0] + A[1][0] + A[2][0]
if x == 0:
    ans = "Yes"
x = A[0][1] + A[1][1] + A[2][1]
if x == 0:
    ans = "Yes"
x = A[0][2] + A[1][2] + A[2][2]
if x == 0:
    ans = "Yes"

# naname
x = A[0][0] + A[1][1] + A[2][2]
if x == 0:
    ans = "Yes"
x = A[2][0] + A[1][1] + A[0][0]
if x == 0:
    ans = "Yes"


print(ans)

Submission status: Wrong Answer

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

n = int(input())

ans = []
for _ in range(3):
  ans += [0]*3
  
for _ in range(n):
  b = int(input())
  if b in a:
    ans[a.index(b)] = 1
    
f = False
for i in range(3):
  if sum(ans[3*i:3*i+3]) == 3:
    f = True

for i in range(3):
  if sum(ans[3*i::3]) == 3:
    f = True
    
if (ans[0] + ans[4] + ans[8]) == 3:
  f = True
if (ans[2] + ans[4] + ans[6]) == 3:
  f = True
  
if f:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            idx = a[j].index(b)
            a[j][idx] = 0
for k in range(3):
    if sum(a[k]) == 0:
        print('Yes')
        exit()
    elif a[k][0] + a[k][1] + a[k][2] == 0:
        print("Yes")
        exit()
if a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0:
    print('Yes')
else:
    print('No')

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 = [[], [], []]
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            S[i].append(1)
        else:
            S[i].append(0)

t = 0


for i in range(3):
    if sum(S[i]) == 3:
        t = 1
    for j in range(3):
        if sum([S[j][i] for i in range(3)]) == 3:
            t = 1
if S[0][0] + S[1][1] + S[2][2] == 3 or S[0][2] + S[1][1] + S[2][0] == 3:
    t = 1

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

Submission status: Wrong Answer

Solution code:
a = [0 for i in range(9)]
c = [0 for i in range(9)]
a[0],a[1],a[2] = map(int,input().split())
a[3],a[4],a[5] = map(int,input().split())
a[6],a[7],a[8] = map(int,input().split())
n = int(input())
for i in range(n):
    b= int(input())
    for j in range(9):
        if a[j] == b:
            c[j] = 1

ans = 'No'
if i in range(3):
    if c[3*i]+c[3*i+1]+c[3*i+2] == 3:
        ans = 'Yes'

if i in range(3):
    if c[i]+c[3+i]+c[6+i] == 3:
        ans = 'Yes'

if c[0]+c[4]+c[8] == 3:
    ans = 'Yes'
if c[2]+c[4]+c[6] == 3:
    ans = 'Yes'

print(ans)

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 = [input() for _ in range(n)]
if (a and b and c) in A:
    print("Yes")
elif (d and e and f) in A:
    print("Yes")
elif (g and h and i) in A:
    print("Yes")
elif (a and d and g) in A:
    print("Yes")
elif (b and e and h) in A:
    print("Yes")
elif (c and f and i) in A:
    print("Yes")
elif (a and e and i) in A:
    print("Yes")
elif (c and e and g) in A:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

for i in range(3):
    for j in a[i]:
        if j != 0:
            break
    else:
        print('Yes')
        break
    if a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
        print('Yes')
        break
    if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        print('Yes')
        break
    if 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:
num_card = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())
b_array = [int(input()) for _ in range(n)]

card = [[False for _ in range(3)] for _ in range(3)]

for b in b_array:
    for i in range(3):
        for j in range(3):
            if num_card[i][j] == b:
                card[i][j] = True

bingo = False

for i in range(3):
    if all(card[i]):
        bingo = True
        break
    if all((card[0][i], card[1][i], card[2][j])):
        bingo = True
        break

if all([card[i][i] for i in range(3)]):
    bingo = True

if all([card[i][2-i] for i in range(3)]):
    bingo = True

print("Yes" if bingo else "No")

Submission status: Wrong Answer

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
a = [[int(j) for j in input().split()] for i in range(3)]
# print(a)
n = int(input())
ans = [[0] * 3] * 3
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                ans[j][k] = 1

if ans[0][0] == ans[0][1] == ans[0][2] == 1:
    print("Yes")
elif ans[1][0] == ans[1][1] == ans[1][2] == 1:
    print("Yes")
elif ans[2][0] == ans[2][1] == ans[2][2] == 1:
    print("Yes")

elif ans[0][0] == ans[1][0] == ans[2][0] == 1:
    print("Yes")
elif ans[0][1] == ans[1][1] == ans[2][1] == 1:
    print("Yes")
elif ans[0][2] == ans[1][2] == ans[2][2] == 1:
    print("Yes")

elif ans[0][0] == ans[1][1] == ans[2][2] == 1:
    print("Yes")
elif ans[0][2] == ans[1][1] == ans[2][0] == 1:
    print("Yes")

else:
    print("No")

Submission status: Wrong Answer

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

ans="No"
for i in range(3):
    #縦
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        ans="Yes"
        break
    #横
    if a[0][i] in b and a[0][i] in b and a[0][i] in b:
        ans="Yes"
        break
#斜め
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        ans="Yes"
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
        ans="Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
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
    cross = 0
    ucross = 0
    for j in range(3):
        if sum(a[j][:]) == 0:
            print("Yes")
            exit()
        if sum(a[:][j]) == 0:
            print("Yes")
            exit()
        cross += a[j][j]
        ucross += a[2-j][2-j]
    if cross == 0:
        print("Yes")
        exit()
    if ucross == 0:
        print("Yes")
        exit()
         
print("No")