Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

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

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

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

Sample Input 2

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

Sample Output 2

No

We will mark nothing.

Sample Input 3

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

Sample Output 3

Yes

We will mark all the squares.



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


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = set([int(input()) for _ in range(N)])
flag = False
# yoko
for i in range(3):
    if all([a in b for a in A[i]]):
        flag = True

if not flag:
    for j in range(3):
        tmp = [A[j][0], A[j][1], A[j][2]]
        if all([a in b for a in tmp]):
            flag = True

if not flag:
    tmp = [A[0][0], A[1][1], A[2][2]]
    if all([a in b for a in tmp]):
        flag = True

if not flag:
    tmp = [A[0][2], A[1][1], A[2][0]]
    if all([a in b for a in tmp]):
        flag = True

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

Submission status: Wrong Answer

Solution code:
import sys

a = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]
n, *b = map(int, sys.stdin.read().split())
b = set(b)

def main():
    res = [[False] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                res[i][j] = True 
    
    for i in range(3):
        for j in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for j in range(3):
        for i in range(3):
            if not res[i][j]:
                break
        else:
            return 'Yes'
    
    for i, j in zip(range(3), range(3)):
        if not res[i][j]:
            break
        else:
            return 'Yes'
    
    for i, j in zip(range(3), range(2, -1, -1)):
        if not res[i][j]:
            break
        else:
            return 'Yes'
    
    return 'No'

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import numpy as np


a = []

for i in range(3):
    a.append(list(map(int, input().split())))

#print(a)

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
                break

#print(a)

ans = min(sum(a[0]), sum(a[1]), sum(a[2]))
ans = min(ans, (a[0][0] + a[1][1] + a[2][2]),(a[0][2] + a[1][1] + a[2][0]))



a = np.array(a)
a.T
ans = min(ans,min(sum(a[0]), sum(a[1]), sum(a[2])))

print(["No","Yes"][ans == 0])

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	A = []
	S = [[False,False,False] for i in range(3)]
	for i in range(3):
		a=LI()
		A.append(a)
	N = II()
	for _ in range(N):
		b = II()
		for i in range(3):
			for j in range(3):
				if(A[i][j]==b):
					S[i][j]=True
	if((S[0][0]==S[0][1]==S[0][2]==True) or (S[1][0]==S[1][1]==S[1][2]==True) or (S[2][0]==S[2][1]==S[2][2]==True) or (S[0][0]==S[1][1]==S[2][2]==True) or (S[2][0]==S[1][1]==S[0][2]==True)):
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
# ABC157b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと
    bing = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for num in b:
        for i in bing:
            try:
                while True:
                    t = i.index(num)
                    i[t] = -1
            except:
                continue
    # print(bing)

    naname = [((0, 0), (1, 1), (2, 2)), (2, 0), (1, 1), (0, 2)]
    if sum(bing[0]) == -3 or sum(bing[1]) == -3 or sum(bing[2]) == -3 or bing[0][0]+bing[0][1]+bing[0][2] == -3 or bing[1][0]+bing[1][1]+bing[1][2] == -3 or bing[2][0]+bing[2][1]+bing[2][2] == -3 or bing[0][0]+bing[1][1]+bing[2][2] == -3 or bing[0][2]+bing[1][1]+bing[2][0] == -3:
        print('Yes')
        exit(0)

    print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
class Bar:
    def __init__(self, a, b, c):
        self.a = a
        self.b = b
        self.c = c
        self.left = False
        self.center = False
        self.right = False

    def open(self, v):
        if v == self.a:
            self.left = True
        elif v == self.b:
            self.center = True
        elif v == self.c:
            self.right = True

    def bingo(self):
        return all([self.left, self.right, self.center])


top = Bar(*map(int, input().split()))
center = Bar(*map(int, input().split()))
bottom = Bar(*map(int, input().split()))
for x in range(int(input())):
    value = int(input())
    top.open(value)
    center.open(value)
    bottom.open(value)


def ok():
    print("Yes")
    exit()


if top.bingo() or center.bingo() or bottom.bingo():
    ok()

if top.left == center.left == bottom.left == True:
    ok()

if top.center == center.center == bottom.center == True:
    ok()

if top.right == center.right == bottom.center == True:
    ok()

if top.left == center.center == bottom.right == True:
    ok()

if top.right == center.center == bottom.left == True:
    ok()

print('No')

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
    bingo.append(list(map(int,input().split())))
n = int(input())
for i in range(n):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == bingo[j][k]:
                bingo[j][k] = 0
for i in range(3):
    if bingo[i] == [0, 0, 0]:
        print("Yes")
        exit()
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += bingo[i][j]
    if cnt == 0:
        print("Yes")
        exit()
if bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:
    print("Yes")
    exit()
if bingo[0][2] == bingo[1][1] == bingo[2][0] == 0:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:

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

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

f=False
for i in range(3):
    if sum(bingo[i])==3:
        f=True
    if bingo[0][i]+bingo[1][i]+bingo[2][i] == 3:
        f=True
if bingo[0][0]+bingo[1][1]+bingo[2][2] == 3:
    f=True
if bingo[0][2]+bingo[1][1]+bingo[2][0]:
    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())
b = [int(input()) for i in range(N)]
for k in range(N):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[k]:
                a[i][j] = 0

ans = 'Yes'
for i in range(3):
    cnt = 0
    for j in range(3):
        if a[i][j] != 0:
            break
        else:
            cnt += 1
    if cnt == 3:
        break
if cnt == 3:
    print(ans)
    exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        if a[j][i] != 0:
            break
    if cnt == 3:
        break

if cnt == 3:
    print(ans)
    exit()

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

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:
import numpy as np
a = []
for _ in range(3):
    a.append(list(map(int, input().split())))
a = list(np.array(a).flatten() )
N = int(input())
index = []
for _ in range(N):
    b_i = int(input())
    if b_i in a:
        index.append(a.index(b_i))
index = sorted(list(set(index)))

for i in index:
    if i + 1 in index and i + 2 in index:
        print("Yes")
        exit()
    if i + 2 in index and i + 4 in index:
        print("Yes")
        exit()
    if i + 3 in index and i + 6 in index:
        print("Yes")
        exit()
    if i + 4 in index and i + 4 in index:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():

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

    B = np.zeros([3,3])

    N = int(input())
    for i in range(N):
        b = int(input())
        B[A == b] = 1


    for i in range(3):
        if B[i,:].all():
            print('Yes')
            return
        if B[i,:].all():
            print('Yes')
            return
    
    if B[0,0] == B[1,1] == B[2,2] == 1:
        print('Yes')
        return

    if B[2,0] == B[1,1] == B[0,2] == 1:
        print('Yes')
        return

    print('No')
    return

main()

Submission status: Wrong Answer

Solution code:
bingo_dict = dict()
i=1
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1
i=2
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1
i=3
j=1
for a in [int(i) for i in input().split()]:
    bingo_dict[a] = i*10+j
    j+=1

N = int(input())

s = set()
for b in [int(input()) for n in range(N)]:
    if b in bingo_dict:
        s.add(bingo_dict[b])

patterns = [
    [11,12,12],
    [21,22,23],
    [31,32,33],
    [11,21,31],
    [12,22,32],
    [13,23,33],
    [11,22,33],
    [13,22,31]
]

for p in patterns:
    b = True
    for v in p:
        if v not in s:
            b = False
            break
    if b:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

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

ans=0
for i in range(3):
    cand = a[i]
    ans0=sum(aa in cand for aa in b)
    if ans0 ==3:
        ans=1
for i in range(3):
    cand=[a[i][j] for j in range(3)]
    ans0=sum(aa in cand for aa in b)
    if ans0 ==3:
        ans=1
        
naname1 = [ a[i][i] for i in range(3)]
ans0 = sum(aa in cand for aa in b)
if ans0==3:
    ans=1
    
naname1 = [ a[i][2-i] for i in range(3)]
ans0 = sum(aa in cand for aa in b)
if naname1 ==3:
    ans=1
    
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline

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


B = [[0] * 3] * 3

N = int(input())
for _ in range(N):
    x = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == x:
                B[i][j] = 1

found = False

for i in range(3):
    if sum(B[i]) == 3:
        found = True

for j in range(3):
    sm = 0
    for i in range(3):
        sm += B[i][j]
    if sm == 3:
        found = True

sm = 0
for i in range(3):
    sm += B[i][i]
if sm == 3:
    found = True

sm = 0
for i in range(3):
    sm += B[i][2 - i]
if sm == 3:
    found = True

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

Submission status: Wrong Answer

Solution code:
import sys
# list(map(int,input().split()))

#n = int(input())

#print((n+1)//2)

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

for j in range(3):
  if a[j][0] in b and a[j][1] in b and a[j][2]:
    print('Yes')
    sys.exit()
  
for j in range(3):
  if a[0][j] in b and a[1][j] in b and a[2][j]:
    print('Yes')
    sys.exit()

if a[0][0] in b and a[1][1] in b and a[2][2]:
  print('Yes')
  sys.exit()

if a[0][2] in b and a[1][1] in b and a[2][0]:
  print('Yes')
  sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:

grid = []
for row in range(3):
    row = list(map(int, input().split()))
    grid.append(row)
# print(grid)
n = int(input())

for _ in range(n):
    num = int(input())
    for row in range(3):
        for col in range(3):
            if grid[row][col] == num:
                grid[row][col] = '*'
# print(grid)

# row
is_ok = False
for row in range(3):
    if grid[row][0] == grid[row][1] == grid[row][2] == '*':
        is_ok = True
        break

# col    
for col in range(3):
    if grid[0][col] == grid[1][col] == grid[2][col] == '*':
        is_ok = True
        break

# ななめ
if grid[0][0] == grid[1][1] == grid[2][2] == '*':
    is_ok = True

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

Submission status: Wrong Answer

Solution code:
A = []
for _ in range(3):
    A.append([int(i) for i in input().split()])
N = int(input())
B = []
for _ in range(N):
    B.append(int(input()))
matrix = [[0,0,0],[0,0,0],[0,0,0]]
def check(m):
    for i in range(3):
        if sum(m[i])==3:
            return True
    for ii in range(3):
        if sum(m[:][i])==3:
            return True
    if m[0][0] + m[1][1] + m[2][2] == 3:
        return True
    if m[2][0] + m[1][1] + m[0][2] == 3:
        return True
    return False
for b in B:
    for i in range(3):
        for ii in range(3):
            if A[i][ii] == b:
                matrix[i][ii] = 1
print("Yes") if check(matrix) else print("No")

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
bingo = [[False, False, False] for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                bingo[i][j] = True

# print('A', A, N, b, bingo)

for i in range(3):
    if sum(bingo[i]) == 3:
        print('Yes')
        exit()
for i in range(3):
    tmp = [bingo[0][i], bingo[1][i], bingo[2][i]]
    # print('tmp', tmp, sum(tmp))
    if sum(tmp) == 3:
        print('Yes')
        exit()

tmp = [bingo[0][0], bingo[1][1], bingo[2][2]]
# print('tmp', tmp, sum(tmp))
if sum(tmp) == 3:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
dic = defaultdict(int)

for i in range(3):
    a,b,c = map(int,input().split())
    dic[a] = i*3+1
    dic[b] = i*3+2
    dic[c] = i*3+3
ansl = []
n = int(input())
for _ in range(n):
    k = int(input())
    if dic[k]:
        ansl.append(dic[k])
import itertools
p = itertools.permutations(ansl, 3)
for i in p:
    if sum(i) % 3 == 0:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = [LIST() for i in range(3)]
N = INT()
B = [INT() for i in range(N)]
T = [[False] * 3 for i in range(3)]

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

# tate
for i in range(3):
    if T[i][0] == T[i][1] == T[i][2] == True:
        print("Yes")
        exit()
for i in range(3):
    if T[0][i] == T[1][i] == T[2][i] == True:
        print("Yes")
        exit()

if T[0][0] == T[1][1] == T[2][2] == True:
    print("Yes")
    exit()
print("No")

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):
    if sum(flags[r::1]) == 3:
        ans = True
    if sum(flags[r::3]) == 3:
        ans = True
if sum(flags[0::4]) == 3:
    ans = True
if sum(flags[2::2]) == 3:
    ans = True
if ans:
    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())

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

ans='No'
for i in a:
  if list(i)==[-1,-1,-1]:
    ans='Yes'
for i in zip(*a):
  if list(i)==[-1,-1,-1]:
    ans='Yes'
if a[0][0]+a[1][1]+a[2][2]==-3:
  ans='Yes'
if a[2][2]+a[1][1]+a[0][0]==-3:
  ans='Yes'


print(ans)

Submission status: Wrong Answer

Solution code:
A = [[],[],[]]
A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

cnt = [0 for _ in range(8)]
for i in range(3):
    if A[i][0] in b:
        cnt[0] += 1
    if A[i][1] in b:
        cnt[1] += 1
    if A[i][2] in b:
        cnt[2] += 1
    if A[0][i] in b:
        cnt[3] += 1
    if A[1][i] in b:
        cnt[4] += 1
    if A[2][i] in b:
        cnt[5] += 1
    if A[i][i] in b:
        cnt[6] += 1
    if A[i][2-i] in b:
        cnt[7] += 1
if sum(cnt) > 0:
    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())
for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b:
            a1[j]=0
        if a2[j]==b:
            a2[j]=0
        if a3[j]==b:
            a3[j]=0
answer='No'
if a1.count(0)==3 or a2.count(0)==3 or a3.count(0)==3:
    answer='Yes'
elif a1[0]==0 and a2[1]==0 and a3[2]==0:
    answer='Yes'
elif a1[2]==0 and a2[1]==0 and a3[0]==0:
    answer='Yes'
print(answer)

Submission status: Wrong Answer

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
c=[[False]*3 for _ in range(3)]

n=int(input())
for i in range(n):
    b=int(input())
    for g in range(3):
        for l in range(3):
            if b==a[g][l]:
                c[g][l]=True

if c[0][0] is True and c[1][1] is True and c[2][2] is True:
    print("Yes")
    exit()

if c[0][2] is True and c[1][1] is True and c[2][0] is True:
    print("Yes")
    exit()

for i in range(3):
    if c[i]==[True]*3:
        print("Yes")
        exit()

for i in range(3):
    if c[i][0] is True and c[i][1] is True and c[i][2] is True:
        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())

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

yes = False

for i in range(3):
    if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
        yes = True
    elif A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        yes = True
    elif A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
        yes = True
    elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
        yes = True


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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    A = [tuple(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]

    ans = [[[] for _ in range(3)] for _ in range(3)]
    for i, A_ in enumerate(A):
        for j, a in enumerate(A_):
            ans[i][j] = a in B
    if (all(ans[0]) or all(ans[1]) or all(ans[1])
        or all([ans[0][0], ans[1][0], ans[2][0]])
        or all([ans[0][1], ans[1][1], ans[2][1]])
        or all([ans[0][2], ans[1][2], ans[2][2]])
        or all([ans[0][0], ans[1][1], ans[2][2]])
        or all([ans[2][0], ans[1][1], ans[0][2]])):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
A = [[int(i) for i in input().split()] for _ in range(3)]
B = [[False, False, False], [False, False, False], [False, False, False]]
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:
                B[j][k]=True
for r in B:
    if all(r):
        print("Yes")
        quit()

for c in zip(B):
    if all(*c):
        print("Yes")
        quit()
# print(B)
if (B[0][0] and B[1][1] and B[2][2]) or (B[0][2] and B[1][1] and B[2][0]):
    print("Yes")
    quit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    a = [[False] * 3 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] = True
    for i in range(3):
        if all(a[i]):
            print("Yes")
            return
    for j in range(3):
        if all(a[:][j]):
            print("Yes")
            return
    if a[0][0] and a[1][1] and a[2][2]:
        print("Yes")
        return
    if a[0][2] and a[1][1] and a[2][0]:
        print("Yes")
        return
    print("No")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

A = []
for i in range(3):
    A.append(LI())
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

tables = [[0,0,0] for i in range(3)]
for n in range(N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == b[n]:
                tables[i][j] = 1

ans = 0
for i in range(3):
    if tables[i][0] == tables[i][1] == tables[i][2] == 1:
        ans = 1
    if tables[0][i] == tables[1][i] == tables[2][i] == 1:
        ans = 1
    if tables[i][i] == tables[i][i] == tables[i][i] == 1:
        ans = 1
    if tables[0][2] == tables[1][1] == tables[2][0] == 1:
        ans = 1

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

def main():
    mtrx = []
    for _ in range(3):
        li = list(map(int, input().split()))
        mtrx.append(li)
        
    n = int(input())
    for _ in range(n):
        num = int(input())
        for i in range(3):
            for j in range(3):
                if mtrx[i][j] == num:
                    mtrx[i][j] = -1

    for i in range(3):
        for j in range(3):
            if mtrx[i][j] != -1:
                break
        else:
            print('Yes')
            break
    else:
        if mtrx[0][0] == -1 and mtrx[1][1] == -1 and mtrx[2][2] == -1:
            print('Yes')
            return
        if mtrx[2][0] == -1 and mtrx[1][1] == -1 and mtrx[0][2] == -1:
            print('Yes')
            return
        print('No')

if __name__ == '__main__':
    main()

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  
for bj in range(3):
  if bingo[0][bj]==bingo[1][bj]==bingo[1][bj]==1: flag=True
if bingo[0][0]==bingo[1][1]==bingo[2][2]==1: flag=True
if flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

bingo = False
# 横
for i in range(3):
    if A[i][:] == [0, 0, 0]:
        bingo = True
        break
# 縦
for j in range(3):
    if A[:][j] == [0, 0, 0]:
        bingo = True
        break

# 斜め
if [A[0][0], A[1][1], A[2][2]] == [0, 0, 0]:
    bingo = True

if [A[0][2], A[1][1], A[2][0]] == [0, 0, 0]:
    bingo = True

if bingo == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a1=[int(i) for i in input().split()]
a2=[int(i) for i in input().split()]
a3=[int(i) for i in input().split()]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b: a1[j]=-1
        if a2[j]==b: a1[j]=-1
        if a3[j]==b: a1[j]=-1
print("Yes" if sum(a1)==-3 or sum(a2)==-3 or sum(a3)==-3 or a1[0]+a2[1]+a3[2]==-3 or a1[2]+a2[1]+a3[0]==3 else "No" )

Submission status: Wrong Answer

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

#print("Yes") print("No")

lll=[]
for i in range(3):
    for j in range(3):
        if l[i][j] in ll:
            lll.append([i,j])

a=0
if [0,0] and [0,1] and [0,2] in lll:
    a+=1
if [1,0] and [1,1] and [1,2] in lll:
    a+=1
if [2,0] and [2,1] and [2,2] in lll:
    a+=1
if [0,0] and [1,0] and [2,0] in lll:
    a+=1
if [0,1] and [1,1] and [2,1] in lll:
    a+=1
if [0,2] and [1,2] and [2,2] in lll:
    a+=1
if [0,0] and [1,1] and [2,2] in lll:
    a+=1
if [0,2] and [1,1] and [0,2] in lll:
    a+=1

if a==0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
    aa = list(map(int, input().split()))
    a.append(aa)
n = int(input())
flag = []
for i in range(3):
    flag.append([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:
                flag[j][k] = 1
ans = False
for j in range(3):
    if flag[0][j] == 1 and flag [1][j] == 1 and flag[2][j] == 1:
        ans = True
for i in range(3):
    if flag[i][j] == 1 and flag [i][0] == 1 and flag[i][0] == 1:
        ans = True
if flag[0][0] == 1 and flag [1][1] == 1 and flag[2][2] == 1:
        ans = True
if flag[2][0] == 1 and flag [1][1] == 1 and flag[0][2] == 1:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

A_list = []
A_list.append(list(map(int, input().split())))
A_list.append(list(map(int, input().split())))
A_list.append(list(map(int, input().split())))
N = int(input())

B_list = [[False] * 3 for _ in range(3)]

for _ in range(N):
	b = int(input())
	for i in range(3):
		for j in range(3):
			if b == A_list[i][j]:
				B_list[i][j] = True

def check():
	for i in range(3):
		if all(B_list[i]) or all(map(lambda j: B_list[i][j], range(3))):
			return True
	
	if all(map(lambda i : B_list[i][i], range(3))) or all(map(lambda i : B_list[i][2 - i], range(3))):
		return True
	
	return False

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

Submission status: Wrong Answer

Solution code:

# n,m=map(int,input().split())
# a,b,c=map(int,input().split())
# s=input()
# s,t=map(str,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
L=[]
L.append(A)
L.append(B)
L.append(C)
n=int(input())

for i in range(n):
  x=int(input())
  for a in range(3):
    for b in range(3):
      if L[a][b] == x:
        L[a][b]=0

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

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

if L[2][0]==0 and L[2][1]==0 and L[2][2]==0:
  print("Yes")
  exit()
  
if L[0][0]==0 and L[1][1]==0 and L[2][2]==0:
  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())
l = [int(input()) for i in range(n)]
if a11 and a12 and a13 in l :
    print('Yes')
elif a21 and a22 and a23 in l:
    print('Yes')
elif a31 and a32 and a33 in l :
    print('Yes')
elif a11 and a21 and a31 in l :
    print('Yes')
elif a22 and a12 and a32 in l:
    print('Yes')
elif a13 and a23 and a33 in l :
    print('Yes')
elif a11 and a22 and a33 in l :
    print('Yes')
elif a13 and a22 and a31 in l:
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
dp = [[0]*3 for i in range(3)]
L = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
L = [a,b,c]
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

flag = 0 

for i in range(3):
    for j in range(3):
        if L[i][j] in l:
            dp[i][j] = 1
for i in range(3):
    if sum(dp[i]) ==3:
        flag = 1

for i in range(3):
    s = 0
    for j in range(3):
        s+= dp[i][j]
    if s == 3:
        flag = 1
s = 0
t = 0
for i in range(3):
    s+=  dp[i][i]
    t+= dp[i][2-i]
if s==3 or t == 3:
    flag = 1
    
if flag:
    print('Yes')
else:
    print('No')
# print(dp)

Submission status: Wrong Answer

Solution code:

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

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

f=False
for i in range(3):
    if sum(bingo[i])==3:
        f=True
    if bingo[i][0]+bingo[i][1]+bingo[i][2] == 3:
        f=True
if bingo[0][0]+bingo[1][1]+bingo[2][2] == 3:
    f=True
if bingo[0][2]+bingo[1][1]+bingo[2][0]:
    f=True
if f:
    print("Yes")
else:
    print("No")