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:
#coding:utf-8
#!/usr/bin/python

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

C=[[0 for i in range(3)] for j in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if(A[j][k]==b[i]):
               C[j][k]=1

print C
kekka='No'

for i in range(3):
    m=0
    for j in range(3):
        m=m+C[i][j]
    if(m==3):
       kekka='Yes'
       break
            
for i in range(3):
    m=0
    for j in range(3):
        m=m+C[j][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][2-i]
    if(m==3):
       kekka='Yes'
       break

print kekka

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

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

for i in range(3):
    for j in range(N):
        if A[i][0] == n[j]:
            for k in range(N):
                if A[i][1] == n[k]:
                    for l in range(N):
                        if A[i][2] == n[l]:
                            print('Yes')
                            sys.exit()

for j in range(N):
    if A[0][0] == n[j]:
        for k in range(N):
            if A[1][1] == n[k]:
                for l in range(N):
                    if A[2][2] == n[l]:
                        print('Yes')
                        sys.exit()

for j in range(N):
    if A[2][0] == n[j]:
        for k in range(N):
            if A[1][1] == n[k]:
                for l in range(N):
                    if A[2][0] == n[l]:
                        print('Yes')
                        sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

A = np.array([list(map(int, input().split())) for _ in range(3)])
N = int(input())
n = [int(input()) for _ in range(N)]

for i in range(3):
    for j in range(N):
        if A[i,0] == n[j]:
            for k in range(N):
                if A[i,1] == n[k]:
                    for l in range(N):
                        if A[i,2] == n[l]:
                            print('Yes')
                            sys.exit()

for j in range(N):
    if A[0,0] == n[j]:
        for k in range(N):
            if A[1,1] == n[k]:
                for l in range(N):
                    if A[2,2] == n[l]:
                        print('Yes')
                        sys.exit()

for j in range(N):
    if A[2,0] == n[j]:
        for k in range(N):
            if A[1,1] == n[k]:
                for l in range(N):
                    if A[2,0] == n[l]:
                        print('Yes')
                        sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

bingo_list = np.array([list(map(int, input().split())) for _ in range(3)])
N = int(input())
n = [int(input()) for _ in range(N)]

A = np.array([[41,7,46],[26,89,2],[78,92,8]])

for i in range(3):
    for j in range(N):
        if A[i,0] == n[j]:
            for k in range(N):
                if A[i,1] == n[k]:
                    for l in range(N):
                        if A[i,2] == n[l]:
                            print('Yes')
                            sys.exit()

for j in range(N):
    if A[0,0] == n[j]:
        for k in range(N):
            if A[1,1] == n[k]:
                for l in range(N):
                    if A[2,2] == n[l]:
                        print('Yes')
                        sys.exit()

for j in range(N):
    if A[2,0] == n[j]:
        for k in range(N):
            if A[1,1] == n[k]:
                for l in range(N):
                    if A[2,0] == n[l]:
                        print('Yes')
                        sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

A = np.empty(9)
b = np.empty(10)
place = ''

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

N = int(input())

for n in range(N):
  b[n] = int(input())
  for j in range(9):
  	if b[n] == A[j]:
  		place = place + ' ' + str(j)

if '0' and '1' and '2' in place:
	ans = 'Yes'
elif '3' and '4' and '5' in place:
	ans = 'Yes'
elif '6' and '7' and '8' in place:
	ans = 'Yes'
elif '0' and '3' and '6' in place:
	ans = 'Yes'
elif '1' and '4' and '7' in place:
	ans = 'Yes'
elif '2' and '5' and '8' in place:
	ans = 'Yes'
elif '0' and '4' and '8' in place:
	ans = 'Yes'
elif '2' and '4' and '6' in place:
	ans = 'Yes'
else:
	ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    a11, a12, a13 = LI()
    a21, a22, a23 = LI()
    a31, a32, a33 = LI()
    n = I()
    b = IR(n)
    if a11 in b and a12 in b and a13 in b:
        print('Yes')
    elif a21 in b and a22 in b and a23 in b:
        print('Yes')
    elif a31 in b and a32 in b and a33 in b:
        print('Yes')
    elif a11 in b and a22 in b and a33 in b:
        print('Yes')
    elif a13 in b and a22 in b and a31 in b:
        print('Yes')
    else:
        print('No')
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

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

card = [[A11, A12, A13],
        [A21, A22, A23],
        [A31, A32, A33]]

h = [[0, 0, 0],
     [0, 0, 0],
     [0, 0, 0]]

a = []

for l in sys.stdin:
    a.append(int(l))

for i in a:
    for j in range(3):
        for k in range(3):
            if card[j][k] == i:
                h[j][k] = 1

if max(sum(h[0]), sum(h[1]), sum(h[2])) == 3:
    print("Yes")
elif max((h[0][0] + h[1][0] + h[2][0]), (h[0][1] + h[1][1] + h[2][1]), (h[0][2] + h[1][2] + h[2][2])) == 3:
    print("Yes")
elif max((h[0][0] + h[1][1] + h[2][2]), (h[0][2] + h[1][1] + h[2][2])) == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def bingo_judge(A_input,b):
    bingo=0
    judge_list=[0,0,0,0,0,0,0,0,0]
    for number in b:
        for i in range(9):
            if number==A_input[i]:
                judge_list[i]=1
            else:
                pass
    #horizonal
    for i in range(3):
        if judge_list[3*i]*judge_list[3*i+1]*judge_list[3*i+2]==1:
            bingo=1
        else:
            pass
    #vertical
    for i in range(3):
        if judge_list[i]*judge_list[i+3]*judge_list[i+6]==1:
            bingo=1
        else:
            pass
    #diagonal
    if judge_list[0]*judge_list[4]*judge_list[8]==1:
        bingo=1
    if judge_list[2]*judge_list[4]*judge_list[6]==1:
        bingo=1
    #test display
    # judge_disp=[[judge_list[i+3*n] for i in range(3)] for n in range(3)] 
    # print(*judge_disp,sep="\n")
    
    return bingo

def main():
    #initialize
    A=[]
    N=0
    b=[]
    #input
    A=[list(map(int,input().strip().split())) for n in range(3)]
    A_input=[]
    for n in range(3):
        for m in range(3):
            A_input.append(A[n][m])
    N=int(input())
    b=[int(input()) for n in range(N)]

    ans=bingo_judge(A_input,b)
    if ans==1:
        print("yes")
    elif ans==0:
        print("No")

main()

#test code
test_time=10
def test_code():
    import random
    A_input=[random.randint(1,10) for n in range(9)]
    N=random.randint(1,10)
    b=[random.randint(1,10) for n in range(N)]
    A_disp=[[A_input[i+3*n] for i in range(3)] for n in range(3)] 
    print(b)
    print(*A_disp,sep="\n")
    print(bingo_judge(A_input,b))

# for i in range(test_time):
#     test_code()

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().strip().split())) for n in range(3)]
A_input=[]
for n in range(3):
    for m in range(3):
        A_input.append(A[n][m])
N=int(input())
b=[int(input()) for n in range(N)]

def bingo_judge(A_input,b):
    bingo=0
    judge_list=[0,0,0,0,0,0,0,0,0]
    for number in b:
        for i in range(9):
            if number==A_input[i]:
                judge_list[i]=1
            else:
                pass
    #horizonal
    for i in range(3):
        if judge_list[3*i]*judge_list[3*i+1]*judge_list[3*i+2]==1:
            bingo=1
        else:
            pass
    #vertical
    for i in range(3):
        if judge_list[i]*judge_list[i+3]*judge_list[i+6]==1:
            bingo=1
        else:
            pass
    #diagonal
    if judge_list[0]*judge_list[4]*judge_list[8]==1:
        bingo=1
    if judge_list[2]*judge_list[4]*judge_list[6]==1:
        bingo=1
    #test display
    # judge_disp=[[judge_list[i+3*n] for i in range(3)] for n in range(3)] 
    # print(*judge_disp,sep="\n")
    
    return bingo

def main():
    ans=bingo_judge(A_input,b)
    if ans==1:
        print("yes")
    elif ans==0:
        print("No")
main()

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().strip().split())) for n in range(3)]
A_input=[]
for n in range(3):
    for m in range(3):
        A_input.append(A[n][m])
N=int(input())
b=[int(input()) for n in range(N)]

def bingo_judge(A_input,b):
    bingo=0
    judge_list=[0,0,0,0,0,0,0,0,0]
    for number in b:
        for i in range(9):
            if number==A_input[i]:
                judge_list[i]=1
            else:
                pass
    #horizonal
    for i in range(3):
        if judge_list[3*i]*judge_list[3*i+1]*judge_list[3*i+2]==1:
            bingo=1
        else:
            pass
    #vertical
    for i in range(3):
        if judge_list[i]*judge_list[i+3]*judge_list[i+6]==1:
            bingo=1
        else:
            pass
    #diagonal
    if judge_list[0]*judge_list[4]*judge_list[8]==1:
        bingo=1
    if judge_list[2]*judge_list[4]*judge_list[6]==1:
        bingo=1
    #test display
    # judge_disp=[[judge_list[i+3*n] for i in range(3)] for n in range(3)] 
    # print(*judge_disp,sep="\n")
    
    return bingo

def main():
    if bingo_judge(A_input,b)==1:
        print("yes")
    else:
        print("No")
main()

#test code
test_time=10
def test_code():
    import random
    A_input=[random.randint(1,10) for n in range(9)]
    N=random.randint(1,10)
    b=[random.randint(1,10) for n in range(N)]
    A_disp=[[A_input[i+3*n] for i in range(3)] for n in range(3)] 
    print(b)
    print(*A_disp,sep="\n")
    print(bingo_judge(A_input,b))

# for i in range(test_time):
#     test_code()

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().strip().split())) for n in range(3)]
A_input=[]
for n in range(3):
    for m in range(3):
        A_input.append(A[n][m])
N=int(input())
b=[int(input()) for n in range(N)]

def bingo_judge(A_input,b):
    bingo=0
    judge_list=[0,0,0,0,0,0,0,0,0]
    for number in b:
        for i in range(9):
            if number==A_input[i]:
                judge_list[i]=1
            else:
                pass
    #horizonal
    for i in range(3):
        if judge_list[3*i]*judge_list[3*i+1]*judge_list[3*i+2]==1:
            bingo=1
        else:
            pass
    #vertical
    for i in range(3):
        if judge_list[i]*judge_list[i+3]*judge_list[i+6]==1:
            bingo=1
        else:
            pass
    #diagonal
    if judge_list[0]*judge_list[4]*judge_list[8]==1:
        bingo=1
    if judge_list[2]*judge_list[4]*judge_list[6]==1:
        bingo=1
    #test display
    judge_disp=[[judge_list[i+3*n] for i in range(3)] for n in range(3)] 
    print(*judge_disp,sep="\n")
    
    return bingo

def main():
    if bingo_judge(A_input,b)==1:
        print("yes")
    else:
        print("No")
main()

#test code
test_time=10
def test_code():
    import random
    A_input=[random.randint(1,10) for n in range(9)]
    N=random.randint(1,10)
    b=[random.randint(1,10) for n in range(N)]
    A_disp=[[A_input[i+3*n] for i in range(3)] for n in range(3)] 
    print(b)
    print(*A_disp,sep="\n")
    print(bingo_judge(A_input,b))

# for i in range(test_time):
#     test_code()

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().strip().split())) for n in range(3)]
A_input=[]
for n in range(3):
    for m in range(3):
        A_input.append(A[n][m])
N=int(input())
b=[int(input()) for n in range(N)]

def bingo_judge(A_input,b):
    bingo=0
    judge_list=[0,0,0,0,0,0,0,0,0]
    for number in b:
        for i in range(9):
            if number==A_input[i]:
                judge_list[i]=1
            else:
                pass
    #horizonal
    for i in range(3):
        if judge_list[3*i]*judge_list[3*i+1]*judge_list[3*i+2]==1:
            bingo=1
        else:
            pass
    #vertical
    for i in range(3):
        if judge_list[i]*judge_list[i+3]*judge_list[i+6]==1:
            bingo=1
        else:
            pass
    #diagonal
    if judge_list[0]*judge_list[4]*judge_list[8]==1:
        bingo=1
    if judge_list[2]*judge_list[4]*judge_list[6]==1:
        bingo=1
    return bingo

if bingo_judge(A_input,b)==1:
    print("yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
listA1 = input().split(" ")
listA2 = input().split(" ")
listA3 = input().split(" ")

matrix = [listA1, listA2, listA3]

matrixBool = [[False] * 3] * 3

n = int(input())
bingo = False
for i in range(n):
    a = input()
    for l in range(0,2):
        for j in range(0,2):
            if matrix[l][j]==a:
                matrixBool[l][j] = True

for l in range(3):
    c = 0
    for i in range(3):
        if matrixBool[l][i] == True:
            c = c+1

    if c == 3:
        bingo = True
        break

for l in range(3):
    c = 0
    for i in range(3):
        if matrixBool[i][l] == True:
            c = c + 1

    if c == 3:
        bingo = True
        break

for l in range(3):
    c = 0
    if matrixBool[l][l] == True:
        c = c + 1

    if c == 3:
        bingo = True
        break

if matrixBool[0][2] == True and matrixBool[1][1] == True and matrixBool[2][0] == True:
    bingo = True

if bingo == True:
    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())))
A = np.array(A)

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

res = np.array([int(i in B) for i in A.ravel()]).reshape(3, 3)
diag_sum = res[0 ,0] + res[1, 1] + res[2, 2]
diag_sum2 = res[0, 2] + res[1, 1] + res[2, 0]
if res.sum(axis=0).any() or res.sum(axis=1).any() or diag_sum == 3 or diag_sum2 == 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a = [list(map(int, input().split())) for e in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for i in range(len(a)):
        for j in range(len(a)):
            if a[i][j] in b:
                a[i][j] = 0
    ans = 'No'
    for i in range(len(a)):
        if set(a[i]) == {0}:
            ans = 'Yes'
        if set([a[i][j] for j in range(len(a))]) == {0}:
            ans = 'Yes'
    if set([a[j][j] for j in range(len(a))]) == {0}:
            ans = 'Yes'
    if set([a[len(a) - j - 1][j] for j in range(len(a))]) == {0}:
            ans = 'Yes'
    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a = [list(map(int, input().split())) for e in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for i in range(len(a)):
        for j in range(len(a)):
            if a[i][j] in b:
                a[i][j] = 0
    ans = 'No'
    for e in range(len(a)):
        if set(a[e]) == {0}:
            ans = 'Yes'
        if set([a[i][e] for i in range(len(a))]) == {0}:
            ans = 'Yes'
    if set([a[e][e] for e in range(len(a))]) == {0}:
            ans = 'Yes'
    print(ans)

Submission status: Wrong Answer

Solution code:
a = []
for _ in range(3):
    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

for i in range(3):
    f = True
    for j in range(3):
        if a[i][j] != 0:
            f = False
            break
    if f:
        print("Yes")
        exit(0)
    
    f = True
    for j in range(3):
        if a[j][i] != 0:
            f = False
            break
    if f:
        print("Yes")
        exit(0)

f = True
for i in range(3):
    if a[i][i] != 0:
        f = False
        break
if f:
    print("Yes")
    exit(0)

f = True
for i in range(3):
    if a[2 - i][2 - i] != 0:
        f = False
        break
if f:
    print("Yes")
    exit(0)
    
print("No")

Submission status: Wrong Answer

Solution code:
B=[];bingo=-1
import numpy as np
A=np.zeros((3,3),dtype=int)
for i in range(3):
  a,b,c=map(int,input().split())
  A[i][0]=a
  A[i][1]=b
  A[i][2]=c
N=int(input())
for i in range(N):
  B.append(int(input()))
#print(A)
#print(B)
for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j]==B[k]:
        A[i][j]=0
for i in range(3):
  if sum(A[i][:])==0:
    bingo=1
for i in range(3):
  if sum(A[:][i])==0:
    bingo=1
if A[0][0]+A[1][1]+A[2][2]==0:
  bingo=1
if A[2][0]+A[1][1]+A[0][2]==0:
  bingo=1
print("Yes" if bingo==1 else "No")

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import array
import bisect
import collections
import copy
import fractions
import functools
import heapq
import itertools
import math
import operator
import random
import re
import string
import sys
import time
from collections import Counter, deque
from fractions import Fraction, gcd
from functools import reduce
from heapq import heapify, heappop, heappush, heappushpop, heapreplace
from itertools import accumulate
from operator import mul
from queue import PriorityQueue as pq
from queue import Queue
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    # variants
    s1 = set()
    s2 = set()
    matrix = []
    matrix_check = [[0 for i in range(3)] for j in range(3)]

    # input
    for i in range(3):
        l = list(map(int, input().strip().split()))
        s1.update(l)
        matrix.append(l)
    n = int(input().strip())
    a = [0 for i in range(n)]
    for i in range(n):
        a[i] = int(input().strip())
        s2.add(a[i])
    s_union = s1 & s2

    # processing
    for i in range(len(matrix)):
        for j in range(len(matrix[i])):
            if matrix[i][j] in s_union:
                matrix_check[i][j] = 1
    eprint('matrix_check ', end=':\n')
    eprint(matrix_check) 

    # check
    for i in range(len(matrix_check)):
        if matrix_check[i] == [1, 1, 1] or [row[i] for row in matrix_check] == [1, 1, 1]:
            print("Yes")
            return

    if [matrix_check[i][i] for i in range(3)] == [1,1,1] or [matrix_check[i][-i] for i in range(3)] == [1,1,1]:
        print("Yes")
        return

    print("No")
    return
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import array
import bisect
import collections
import copy
import fractions
import functools
import heapq
import itertools
import math
import operator
import random
import re
import string
import sys
import time
from collections import Counter, deque
from fractions import Fraction, gcd
from functools import reduce
from heapq import heapify, heappop, heappush, heappushpop, heapreplace
from itertools import accumulate
from operator import mul
from queue import PriorityQueue as pq
from queue import Queue
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    # variants
    s1 = set()
    s2 = set()
    matrix = []
    matrix_check = [[0 for i in range(3)] for j in range(3)]

    # input
    for i in range(3):
        l = list(map(int, input().strip().split()))
        s1.update(l)
        matrix.append(l)
    n = int(input().strip())
    a = [0 for i in range(n)]
    for i in range(n):
        a[i] = int(input().strip())
        s2.add(a[i])
    s_union = s1 & s2

    # processing
    for i in range(len(matrix)):
        for j in range(len(matrix[i])):
            if matrix[i][j] in s_union:
                matrix_check[i][j] = 1
    
    # check
    for i in range(len(matrix_check)):
        if matrix_check[i] == [1, 1, 1] or [row[i] for row in matrix_check] == [1, 1, 1]:
            print("Yes")
            return
    
    if [matrix_check[i][i] for i in range(3)] == [1,1,1] or [matrix_check[-i][-i] for i in range(3)] == [1,1,1]:
        print("Yes")
        return        

    print("No")
    return
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n = int(input())

number = [int(input()) for _ in range(n)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == number[i]:
                bingo[j][k] = -1

for i in range(3):
    check = 0
    for j in range(3):
        if bingo[i][j] == -1:
            check += 1
    else:
        if check == 3:
            print("Yes")
            exit()

for i in range(3):
    cehck = 0
    for j in range(3):
        if bingo[j][i] == -1:
            check += 1
    else:
        if check == 3:
            print("Yes")
            exit()
            
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1 or bingo[2][0] == -1 and bingo[1][1] == -1 and bingo[0][2] == -1:
    print("Yes")
    exit()

print("No")
        


print(bingo)
print(number)

Submission status: Wrong Answer

Solution code:
#bingo
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=[a1,a2,a3]
n=int(input())
b=[]
for j in range(n):
    B=int(input())
    b.append(B)

hc1=["out","out","out"]
hc2=["out","out","out"]
hc3=["out","out","out"]

print(a1)
print(a2)
print(a3)

for i in range(3):
    for j in b:
        if a1[i]==j:
            hc1[i]="hit"
for i in range(3):
    for j in b:
        if a2[i]==j:
            hc2[i]="hit"
for i in range(3):
    for j in b:
        if a3[i]==j:
            hc3[i]="hit"

print(hc1)
print(hc2)
print(hc3)

#よこ
if hc1[0]=="hit" and hc1[1]=="hit" and hc1[2]=="hit":
    print("Yes")
elif hc2[0]=="hit" and hc2[1]=="hit" and hc2[2]=="hit":
    print("Yes")
elif hc3[0]=="hit" and hc3[1]=="hit" and hc3[2]=="hit":
    print("Yes")
#たて
elif hc1[0]=="hit" and hc2[0]=="hit" and hc3[0]=="hit":
    print("Yes")
elif hc1[1]=="hit" and hc2[1]=="hit" and hc3[1]=="hit":
    print("Yes")
elif hc1[2]=="hit" and hc2[2]=="hit" and hc3[2]=="hit":
    print("Yes")
#斜め
elif hc1[0]=="hit" and hc2[1]=="hit" and hc3[2]=="hit":
    print("Yes")
elif hc1[2]=="hit" and hc2[1]=="hit" and hc3[0]=="hit":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#bingo
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=[a1,a2,a3]
n=int(input())
b=[]
for j in range(n):
    B=int(input())
    b.append(B)

hc1=["out","out","out"]
hc2=["out","out","out"]
hc3=["out","out","out"]

print(a1)
print(a2)
print(a3)

for i in range(3):
    for j in b:
        if a1[i]==j:
            hc1[i]="hit"
for i in range(3):
    for j in b:
        if a2[i]==j:
            hc2[i]="hit"
for i in range(3):
    for j in b:
        if a3[i]==j:
            hc3[i]="hit"



print(hc1)
print(hc2)
print(hc3)

#よこ
if hc1[0]=="hit" and hc1[1]=="hit" and hc1[2]=="hit":
    print("Yes")
elif hc2[0]=="hit" and hc2[1]=="hit" and hc2[2]=="hit":
    print("Yes")
elif hc3[0]=="hit" and hc3[1]=="hit" and hc3[2]=="hit":
    print("Yes")
#たて
elif hc1[0]=="hit" and hc2[0]=="hit" and hc3[0]=="hit":
    print("Yes")
elif hc1[1]=="hit" and hc2[1]=="hit" and hc3[1]=="hit":
    print("Yes")
elif hc1[2]=="hit" and hc2[2]=="hit" and hc3[2]=="hit":
    print("Yes")
#斜め
elif hc1[0]=="hit" and hc2[1]=="hit" and hc3[2]=="hit":
    print("Yes")
elif hc1[2]=="hit" and hc2[1]=="hit" and hc3[0]=="hit":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
  a.append(list(map(int, input().split())))
d = []
for _ in range(int(input())):
  d.append(int(input()))
for i in range(3):
  t = 0
  t2 = 0
  for j in range(3):
    if a[i][j] in d:
      t += 1
    if a[j][i] in d:
      t2 += 1
    if t == 3 or t2 == 3:
      print("Yes")
      exit()
t = 0
t2 = 0
for i in range(3):
  for j in range(3):
    if i == j and a[i][j] in d:
      t += 1
    if 2 - i == j and a[2 - i][j] in d:
      t2 += 1
if t == 3 or t2 == 3:
  print("Yes")
  exit()
  
print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    import numpy as np

    CARD = np.array(A,dtype=np.int8)

    for i in range(N):
        CARD[CARD==b[i]] = 0   

    CARD = CARD==0

    # 行が揃っているかチェック
    if np.all(CARD,axis=0).sum() > 0:
        print(YES)
        return
    
    if np.all(CARD,axis=0).sum()>0:
        print(YES)
        return
    
    if np.all(np.diag(CARD)):
        print(YES)
        return
    
    if np.all(np.diag(np.fliplr(CARD))):
        print(YES)
        return
    
    print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
li_1 = list(map(int,input().split()))
li_2 = list(map(int,input().split()))
li_3 = list(map(int,input().split()))
ans = []
n = int(input())
li_b = []
for i in range(n):
  b= int(input())
  if b in li_1:
    id = li_1.index(b)
    ans.append(id)
  if b in li_2:
    id = li_2.index(b) + 3
    ans.append(id)
  if b in li_3:
    id = li_3.index(b) + 6
    ans.append(id)
tf = False
ans.sort()
for i in ans:
  if i+1 in ans:
    if i+2 in ans:
      tf = True
  if i+3 in ans:
    if i+6 in ans:
      tf = True
  if 0 in ans:
    if 4 in ans:
      if 8 in ans:
        tf = True
  if 2 in ans:
    if 4 in ans:
      if 6 in ans:
        tf = True
if tf==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
li_1 = list(map(int,input().split()))
li_2 = list(map(int,input().split()))
li_3 = list(map(int,input().split()))
ans = []
n = int(input())
li_b = []
for i in range(n):
  b= int(input())
  if b in li_1:
    id = li_1.index(b)
    ans.append(id)
  if b in li_2:
    id = li_2.index(b) + 3
    ans.append(id)
  if b in li_3:
    id = li_3.index(b) + 6
    ans.append(id)
tf = False
ans.sort()
for i in range(len(ans)):
  if i+1 in ans:
    if i+2 in ans:
      tf = True
  if i+3 in ans:
    if i+6 in ans:
      tf = True
  if 0 in ans:
    if 4 in ans:
      if 8 in ans:
        tf = True
  if 2 in ans:
    if 4 in ans:
      if 6 in ans:
        tf = True
if tf==True:
  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())

k = [int(input()) for p in range(n)]
for s in a:
    if s[0] in k and s[1] in k and s[2] in k:
        print("Yes")
        exit()

for t in range(3):
    if a[0][t] in k and a[1][t] in k and a[2][t] in k:
        print("Yes")
        exit()

if a[0][0] in k and a[1][1] in k and a[2][2] in k:
    print("Yes")
    exit()

if a[0][2] in k and a[1][1] in k and a[2][0] in k:
    print("Yes")
    exit()

print("No")
print(a[1])