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 = [[int(i) for i in input().split()] for j in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

a_true = [[False 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]:
                a_true[j][k] = True
                
bingo = True
                
for i in range(3):
    for j in range(3):
        if a_true[i][j] == False:
            bingo = False
            break
    if bingo == True:
        print('Yes')
        exit()

for i in range(3):
    for j in range(3):
        if a_true[j][i] == False:
            bingo = False
            break
    if bingo == True:
        print('Yes')
        exit()

if a_true[1][1] == True:
    if a_true[0][0] == True:
        if a_true[2][2] == True:
            print('Yes')
            exit()
    elif a_true[0][2] == True:
        if a_true[2][0] == True:
            print('Yes')
            exit()
else:
    print('No')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
alist = [int(i) for i in input().split()]
blist = [int(i) for i in input().split()]
clist = [int(i) for i in input().split()]
n = int(input())
call_num = []
for i in range(n):
  call_num.append(int(input()))
lists = [alist,blist,clist]
dummy_list = [[0 for i in range(3)] for j in range(3)]
for i in call_num:
  for l,jlist in enumerate(lists):
    for m,k in enumerate(jlist):
      if k == i:
        dummy_list[l][m]=1
flag = 0
for i in range(3):
  if sum(dummy_list[i]) == 1:
    flag = 1
  if dummy_list[0][i]+dummy_list[1][i]+dummy_list[2][i]==3:
    flag = 1
if dummy_list[0][0]+dummy_list[1][1]+dummy_list[2][2] == 3:
  flag=1
if dummy_list[2][0]+dummy_list[1][1]+dummy_list[0][2] == 3:
  flag = 1
if flag==1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
    a.append([int(x) for x in input().split()])
bing = [([0]*3),([0]*3),([0]*3)]

N=int(input())
bs = [int(input()) for _ in range(N)]

for b in bs:
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                bing[i][j]=1

def isbingo(board):
    for i in range(3):
        if sum(board[i])==3:
            return True
    for j in range(3):
        if sum([board[i][j] for i in range(3)])==3:
            return True
    if sum([board[0][0],board[1][1],board[2][2]])==3:
        return True
    if sum([board[0][2],board[1][1],board[2][0]])==3:
        return True
    return False
print(a)
print('Yes'if isbingo(bing) else 'No')

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=[[0 for i in range(3)] for j in range(3)]
N=int(input())
if N>=3:
  for i in range(N):
    b=int(input())
    for j in range(3):
      if A[j]==b:
        x[0][j]=1
      elif B[j]==b:
        x[1][j]=1
      elif C[j]==b:
        x[2][j]=1
  flag=0
  if x[0][0]==1:
    if x[0][1]==1 and x[0][2]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[1][1]==1 and x[2][2]==1:
      flag=1
  elif x[1][1]==1:
    if x[0][1]==1 and x[2][1]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[0][2]==1 and x[2][0]==1:
      flag=1
  elif x[2][2]==1:
    if x[2][0]==1 and x[2][1]==1:
      flag=1
    elif x[0][2]==1 and x[1][2]==1:
      flag=1
  if flag==1:
    print("Yes")
  else:
    print("No")
  #print(x)
else:
  print("No")

Submission status: Wrong Answer

Solution code:
ans = "No"
c = []
for i in range(3):
    t = list(map(int, input().split()))
    c.append(t)

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

for i in range(3):
    x = []
    for j in range(3):
        x.append(c[j][i])
    else:
        c.append(x)


for i in range(2):
    x = []
    for j in range(3):
        x.append(c[j][j])
    else:
        c.append(x)

for i in range(8):
    for j in range(3):
        if c[i][j] not in b:
            break
    else:
        ans = "Yes"
        break


print(ans)

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 b:
    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 (X[0] == X[1] == X[2]
    or Y[0] == Y[1] == Y[2]
    or Z[0] == Z[1] == Z[2]
    or X[0] == Y[0] == Z[0]
    or X[1] == Y[1] == Z[1]
    or X[2] == Y[2] == Z[2]
    or X[0] == Y[1] == Z[2]
    or X[2] == Y[1] == Z[0]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = 'No'

    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

    for i in range(3):
        if C[i] == [1,1,1]:
            res = 'Yes'
        if [C[0][i],C[1][i],C[2][i]] == [1,1,1]:
            res == [1,1,1]

    temp1 = [C[0][0],C[1][1],C[2][2]]
    temp2 = [C[0][2],C[1][1],C[2][0]]

    if temp1 == [1,1,1]:
        res = 'Yes'
    if temp2 == [1,1,1]:
        res = 'Yes'

    print(res)



main()

Submission status: Wrong Answer

Solution code:
A = []
A_t = []
for i in range(3):
    A.append(list(map(int, input().split())))
    A_t.append([None] * 3)
for i in range(3):
    for j in range(3):
        A_t[j][i] = A[i][j]
n = int(input())
B = [None] * n
for i in range(n):
    B[i] = int(input())
ans = A + A_t + [[A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]]
for i in range(len(ans)):
    if (all([
        ans[i][0] in B,
        ans[i][1] in B,
        ans[i][2] in B
    ])):
        print('Yes')
        exit()
    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[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:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

L = []
for i in range(3):
	l = list(map(int, stdin.readline().rstrip().split()))
	L.append(l)
# for i in L:
# 	print(i)
N = int(input())
for _ in range(N):
	q = int(input())
	for i in range(3):
		for j in range(3):
			if(L[i][j] == q):
				L[i][j] = -1
f = 0
for i in range(3):
	if(L[i] == [-1,-1,-1]):
		f = 1
if(not f):
	if(L[0][0] == L[1][0] == L[2][0] == -1):
		f = 1
	if(L[0][1] == L[1][1] == L[2][1] == -1):
		f = 1
	if(L[0][2] == L[1][0] == L[2][0] == -1):
		f = 1
	if(L[0][0] == L[1][1] == L[2][2] == -1):
		f = 1
	if(L[0][2] == L[1][1] == L[2][0] == -1):
		f = 1
	
# for i in L:
# 	print(i)
if(f):
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
def iln(): return list(map(int, input().split()))

grid = []
for i in range(3):
    grid.append(iln())


N = int(input())
nums = set()
for i in range(N):
    nums.add(int(input()))


def solve():
    # rows
    for i in range(3):
        if all(map(lambda i: i in nums, grid[i])):
            return True

    # cols
    for i in range(3):
        curr_col = [grid[i][j] for j in range(3)]
        if all(map(lambda i: i in nums, curr_col)):
            return True

    # downhill diagonal
    downhill = [grid[i][i] for i in range(3)]
    if all(map(lambda i: i in nums, downhill)):
        return  True

    # uphill
    uphill = [grid[3 - 1 - i][i] for i in range(3)]
    if all(map(lambda i: i in nums, uphill)):
        return True

    return False

if solve():
    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=list(int(input()) for i in range(n))
c=[[0,0,0] for i in range(3)]

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

if sum(c[0])==3 or sum(c[1])==3 or sum(c[2])==3:
    print('Yes')

elif sum(list(map(lambda x: x[0], c))) or sum(list(map(lambda x: x[1], c))) or sum(list(map(lambda x: x[2], c))):
    print('Yes')

elif (c[0][0]==1 and c[1][1]==1 and c[2][2]==1) or (c[0][2]==1 and c[1][1]==1 and c[2][0]==1):
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

a = [[0] * 3 for _ in range(3)]
a[0] = list(map(int, sys.stdin.readline().strip().split()))
a[1] = list(map(int, sys.stdin.readline().strip().split()))
a[2] = list(map(int, sys.stdin.readline().strip().split()))
n = int(sys.stdin.readline().strip())
b = [0] * n
for i in range(n):
    b = int(sys.stdin.readline().strip())

    for row in range(3):
        for col in range(3):
            if a[row][col] == b:
                a[row][col] = 0


def is_bingo():
    # horizontal
    for r in range(3):
        if a[r][0] + a[r][1] + a[r][2] == 0:
            return True
    # vertical
    for c in range(3):
        if a[0][c] + a[1][c] + a[2][c] + 0:
            return True

    if a[0][0] + a[1][1] + a[2][2] == 0:
        return True
    if a[2][0] + a[1][1] + a[0][2] == 0:
        return True

    return False


if is_bingo():
    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)]

for i in range(3):
    if all(a[i][j] in b for j in range(3)):
        print("Yes")
        quit()
    if all(a[j][i] in b for j in range(3)):
        print("Yes")
        quit()
if all(a[i][i] in b for i in range(3)):
    print("Yes")
    quit()
if all(a[i][2-i] in b for i in range(3)):
    print(i,3-i,"Yes")
    quit()

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):
    is_matched = False
    b = int(input())
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                is_matched = True
                A[row][col] = True
                if A[row][0] == True and A[row][1] == True and A[row][2]:
                    print('Yes')
                    exit()
                elif A[0][col] == True and A[1][col] == True and A[2][col] == True:
                    print('Yes')
                    exit()
                elif A[0][0] == True and A[1][1] == True and A[2][2] == True:
                    print('Yes')
                    exit()
                elif A[0][2] == True and A[1][1] == True and A[2][0] == True:
                    print('Yes')
                    exit()
                break
        if is_matched:
            break
print('No')

Submission status: Wrong Answer

Solution code:
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
x=[[0 for i in range(3)] for j in range(3)]
N=int(input())
if N>=3:
  for i in range(N):
    b=int(input())
    for j in range(3):
      if A[j]==b:
        x[0][j]=1
      elif B[j]==b:
        x[1][j]=1
      elif C[j]==b:
        x[2][j]=1
  flag=0
  if x[0][0]==1:
    if x[0][1]==1 and x[0][2]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[1][1]==1 and x[2][2]==1:
      flag=1
  elif x[1][1]==1:
    if x[0][1]==1 and x[2][1]==1:
      flag=1
    elif x[1][0]==1 and x[2][0]==1:
      flag=1
    elif x[0][2]==1 and x[2][0]==1:
      flag=1
  elif x[2][2]==1:
    if x[2][0]==1 and x[2][1]==1:
      flag=1
    elif x[0][2]==1 and x[1][2]==1:
      flag=1
  if flag==1:
    print("Yes")
  else:
    print("No")
  print(x)
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 tmp3 >= 3):
    print("Yes")
else:
    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)]
    hit = [['n'] * 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:
                    hit[i][i] = 'y'

    correct = ['y'] * 3
    for i in range(3):
        row = hit[i]

        if row == correct:
            print('Yes')
            quit()

        vert = [hit[x][i] for x in range(3)]
        if vert == correct:
            print('Yes')
            quit()

    ri = [hit[0][0], hit[1][1], hit[2][2]]
    if ri == correct:
        print('Yes')
        quit()

    le = [hit[2][0], hit[1][1], hit[2][0]]
    if le == correct:
        print('Yes')
        quit()
    print('No')


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

ans=[set([a[0][0],a[0][1],a[0][2]]),set([a[1][0],a[1][1],a[1][2]]),set([a[2][0],a[2][1],a[2][2]]),set([a[0][0],a[1][0],a[2][0]]),set([a[0][1],a[1][1],a[2][1]]),set([a[0][2],a[1][2],a[2][2]]),set([a[0][0],a[1][1],a[2][2]])]
from itertools import combinations
# listから２つ選ぶ組み合わせ
for i in combinations(b, 3):
    if set(i) in ans:
        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]"):
    bingo_arr = [
        A[0], A[1], A[2],
        [A[0][0], A[1][0], A[2][0]], [A[0][1], A[1][1], A[2][1]], [A[0][2], A[1][2], A[2][2]],
        [A[0][0], A[1][1], A[2][2]], [A[0][2], A[1][1], A[2][0]]
    ]
    for bingo in bingo_arr:
        for i in bingo:
            if i not in b:
                continue
            print(YES)
            return
    print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
from itertools import product
data = [list(map(int, input().split())) for i in range(3)]
n = int(input())
bl = [int(input()) for _ in range(n)]
ok = [[0]*3 for _ in range(3)]

for b in bl:
    for i in range(3):
        for j in range(3):
            if data[i][j] == b:
                ok[i][j] = 1

# print(data)
# print(ok)
if sum(ok[0][:]) == 3 or sum(ok[1][:]) == 3 or sum(ok[2][:]) == 3 or sum(ok[:][0]) == 3 or sum(ok[:][1]) == 3 or sum(ok[:][2]) == 3 or (ok[0][0]+ok[1][1]+ok[2][2]) == 3 or (ok[0][2]+ok[1][1]+ok[2][0]) == 3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = [input().split() for i in range(3)]
N = int(input())
b = [input() for i in range(N)]

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

for i in range(3):
	if A[i][0] == A[i][1] == A[i][2]:
		print('YES')
		exit()
	elif A[0][i] == A[1][i] == A[2][i]:
		print('YES')
		exit()
	elif A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
		print('YES')
		exit()

print('NO')

Submission status: Wrong Answer

Solution code:
#N=int(input())
#N,M=map(int, input().split())
#L=list(map(int, input().split()))
L=[]
Check=[]
for n in range(9):
  Check.append(-(n+1))

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

N=int(input())
for j in range(N):
  I=int(input())
  if I in L:
    Check[L.index(I)]=1
  
for k in range(3):
  if Check[0+3*k]==Check[1+3*k]==Check[2+3*k]:
    print('Yes')
    exit()

for l in range(3):
  if Check[0+l]==Check[3+l]==Check[6+l]:
    print('Yes')
    exit()

if Check[0]==Check[4]==Check[8] or Check[2]==Check[4]==Check[6]:
  print('Yes')
  exit()

print('No')

Submission status: Wrong Answer

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

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

cnt0=0
cnt1=0
cnt2=0
cnt3=0
cnt4=0
cnt5=0
cnt6=0
cnt7=0
ans="No"

for i in range(3):
  if m[0][i]==1:
    cnt0+=1
  if m[1][i]==1:
    cnt1+=1
  if m[2][i]==1:
    cnt2+=1
  if m[i][0]==1:
    cnt3+=1
  if m[i][1]==1:
    cnt4+=1
  if m[i][2]==1:
    cnt5+=1
  if m[i][i]==1:
    cnt6+=1
  if m[i][2-i]==1:
    cnt7+=1

if cnt0==3 or cnt1==3 or cnt2==3 or cnt4==3:
  ans="Yes"
if cnt4==3 or cnt5==3 or cnt6==3 or cnt7==3:
  ans="Yes"  
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

num_array = np.ones((3, 3), int)
for row in range(3):
    num_array[row, :] = list(map(int, input().split()))

n = int(input())
b_list = [int(input()) for i in range(n)]

b_set = set(b_list)
flag = False

for i in range(3):
    tate = set(num_array[i, :])
    yoko = set(num_array[:, i])
    if tate & b_set or yoko & b_set:
        flag = True 

naname_one = set([num_array[0,0], num_array[1,1], num_array[2,2]])
naname_two = set([num_array[0,2], num_array[1,1], num_array[2,0]])
if naname_one & b_set or naname_two & b_set:
    flag = True

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

Submission status: Wrong Answer

Solution code:
# B
import sys
a_list = []
a = []
f = True
c = [False for i in range(9)]
for i in range(3):
    a_list = list(map(int, input().split()))
    for num in a_list:
        a.append(num)
n = int(input())
for i in range(n):
    num = int(input())
    if num in a:
        index = a.index(num)
        c[index] = True
        if (c[0] and c[3] and c[6]) or (c[1] and c[4] and c[7]) or (c[2] and c[5] and c[8]) or (c[0] and c[1] and c[2]) or (c[3] and c[4] and c[5]) or (c[6] and c[7] and c[8]) or (c[0] and c[4] and c[8]) or (c[2] and c[4] and c[6]):
            print('Yes')
            f = False
if f:
    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):
  bingo_num = int(input())
  if bingo_num in A1:
    A1[A1.index(bingo_num)] = 0
  if bingo_num in A2:
    A2[A2.index(bingo_num)] = 0
  if bingo_num in A3:
    A3[A3.index(bingo_num)] = 0
if A1.count(0) == 3 or A2.count(0) == 3 or A3.count(0) == 3\
or A1[0]+A2[0]+A3[0] == 0 or A1[1]+A2[1]+A3[1] == 0 or A1[2]+A2[2]+A3[2] == 0\
or A1[0]+A2[1]+A3[2] == 0 or A1[2]+A2[1]+A3[2]==0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A = list(list(map(int, input().split())) for _ in range(3))
n = int(input())
B = set(int(input()) for _ in range(n))

ans = 'No'

if set(A[0])&B:
  ans = 'Yes'
elif set(A[1])&B:
  ans = 'Yes'
elif set(A[2])&B:
  ans = 'Yes'
elif set([A[0][0], A[1][0], A[2][0]])&B:
  ans = 'Yes'
elif set([A[0][1], A[1][1], A[2][1]])&B:
  ans = 'Yes'
elif set([A[0][2], A[1][2], A[2][2]])&B:
  ans = 'Yes'
elif set([A[0][0], A[1][1], A[2][2]])&B:
  ans = 'Yes'
elif set([A[0][2], A[1][1], A[2][0]])&B:
  ans = 'Yes'
  
print(ans)

Submission status: Wrong Answer

Solution code:
A=[]
B=[[0,0,0],[0,0,0],[0,0,0]]
bseq=[]
for i in range(3):
    a,b,c=map(int,input().split())
    A.append([a,b,c])
n=int(input())
for i in range(n):
    bseq.append(int(input()))
    
for i in range(n):
    for j in range(3):
        for k in range(3):
            if A[j][k]==bseq[i]:
                B[j][k]=1
bingo=0
if B[0][0]==1 and B[0][1]==1 and B[0][2]==1:
    bingo+=1
if B[1][0]==1 and B[1][1]==1 and B[1][2]==1:
    bingo+=1
if B[2][0]==1 and B[2][1]==1 and B[2][2]==1:
    bingo+=1
if B[0][0]==1 and B[1][0]==1 and B[2][0]==1:
    bingo+=1
if B[0][1]==1 and B[1][1]==1 and B[2][1]==1:
    bingo+=1
if B[0][2]==1 and B[1][2]==1 and B[2][2]==1:
    bingo+=1
if B[0][0]==1 and B[1][1]==1 and B[2][2]==1:
    bingo+=1
if B[2][0]==1 and B[1][1]==1 and B[1][2]==1:
    bingo+=1
if bingo>=1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from itertools import product

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 b in B:
    for i, j in product(range(3), repeat=2):
        if A[i][j] == b:
            bingo[i][j] = 1
            break
flag = False
for i in range(3):
    if sum(bingo[i]) == 3:
        flag = True
        break
for j in range(3):
    if sum(bingo[i][j] for i in range(3)) == 3:
        flag = True
        break
if sum(bingo[i][i] for i in range(3)) == 3 or sum(bingo[i][2-i] for i in range(3)):
    flag = True
print('Yes' if flag else 'No')

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(*A):
    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:
a = []
for i in range(3):
    a.append([int(x) for x in input().split()])
bing = [([0]*3),([0]*3),([0]*3)]

N=int(input())
bs = [int(input()) for _ in range(N)]

for b in bs:
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                bing[i][j]=1

def isbingo(board):
    for i in range(3):
        if sum(board[i])==3:
            return True
    for j in range(3):
        if sum([board[i][j] for i in range(3)])==3:
            return True
    if (sum([board[0][0],board[1][1],board[2][2]])):
        return True
    if (sum([board[0][2],board[1][1],board[2][0]])):
        return True
    return False
print('Yes'if isbingo(bing) else 'No')

Submission status: Wrong Answer

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

a=[[0]*3 for _ in range(3)] 
for bi in bl:
    for i in range(3):
        for j in range(3):
            if list1[i][j]==bi:
                a[i][j]=1
ans=0
for i in range(3): # 縦横の判別
    if a[0][i]==1 and a[1][i]==1 and a[2][i]==1:
        ans=1
    if a[i][0]==1 and a[i][0]==1 and a[i][0]==1:
        ans=1
if a[0][0]==1 and a[1][1]==1 and a[2][2]==1:
    ans=1
if a[0][2]==1 and a[1][1]==1 and a[2][0]==1:
    ans=1
if ans==0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
#n = int(input())
#a,b = map(int,input().split())
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))



n = int(input())
b_L = []

for _ in range(n):
    b_L.append(int(input()))

for num in b_L:
    for i in range(0,3):
        if a_1[i] == num:
            a_1[i] = True
        if a_2[i] == num:
            a_2[i] = True
        if a_3[i] == num:
            a_3[i] = True



# 横判定
if a_1.count(True)==3 or a_2.count(True)==3 or a_3.count(True)==3:
    print("Yes")
    exit()

# 縦判定
for i in range(0,3):
    if a_1[i] == True and a_2[i] == True and a_3[i] == True:
        print("Yes")
        exit()

# 斜め判定
if a_1[0] == True and a_2[1] == True and a_3[2] == True:
    print("Yes")
    exit()
if a_1[0] == True and a_2[1] == True and a_3[0] == True:
    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=[]
for _ in range(n):
  b.append(int(input()))
c=[[0]*3 for _ in range(3)]
for i in b:
  for j in a:
    res=0
    cnt=0
    for k in j:
      if i==k:
        c[res][cnt]=1
      cnt+=1
    res+=1
ans="No"
if c[0][0] and c[1][1] and c[2][2]:
  ans="Yes"
if sum(c[0])==3:
  ans="Yes"
if sum(c[1])==3:
  ans="Yes"
if sum(c[2])==3:
  ans="Yes"
if c[0][2] and c[1][1] and c[2][0]:
  ans="Yes"
if c[0][1] and c[0][1] and c[0][2]:
  ans="Yes"
if c[1][1] and c[1][1] and c[1][2]:
  ans="Yes"
if c[2][1] and c[2][1] and c[2][2]:
  ans="Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

A = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

*B, = map(int, input().split())
A[0][0] = B[0]
A[0][1] = B[1]
A[0][2] = B[2]

*B, = map(int, input().split())
A[1][0] = B[0]
A[1][1] = B[1]
A[1][2] = B[2]

*B, = map(int, input().split())
A[2][0] = B[0]
A[2][1] = B[1]
A[2][2] = B[2]

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

#斜めのチェック
if A[0][0]==-1 and A[1][1]==-1 and A[2][2]==-1:
    print("Yes")
    sys.exit()
#縦のチェック
for i in range(3):
    if A[0][i]==-1 and A[1][i]==-1 and A[2][i]==-1:
        print("Yes")
        sys.exit()

for i in range(3):
    if A[i][0]==-1 and A[i][1]==-1 and A[i][2]==-1:
        print("Yes")
        sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# @Time    : 2020/3/1 19:59
# @Author  : DIRICHLET
# @File    : main.py


b=[[0,0,0]]*3
#print(b)
m={}
for i in range(3):
    t=list(map(int,input().split()))
    k=0
    for j in t:
        m[j]=(i,k)
        k+=1
n=input()
for i in n:
    t=int(input())
    if t in m:
        #print(m[t])
        b[m[t][0]][m[t][1]]=1
for i in b:
    ans=1
    for j in i:
        ans*=j
    if ans==1:
        print('Yes')
        exit()
for i in range(3):
    ans=1
    for j in range(3):
        ans*=b[j][i]
    if ans==1:
        print('Yes')
        exit()
if b[0][0]*b[1][1]*b[2][2]==1:
    print('Yes')
    exit()
if b[0][2]*b[1][1]*b[2][0]==1:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:
import math
import sys

input = sys.stdin.readline


def main():
    bingo = [list(map(int, input().split())) for _ in range(3)]
    for _ in range(int(input())):
        n = int(input())
        for i in range(3):
            for j in range(3):
                if bingo[i][j] == n:
                    bingo[i][j] = True

    ret = False
    for i in range(3):
        is_break = False
        for j in range(3):
            if bingo[i][j] is not True:
                is_break = True
                break
        if not is_break:
            ret = True
            break

    if ret is True:
        print('YES')
        return

    for i in range(3):
        is_break = False
        for j in range(3):
            if bingo[j][i] is not True:
                is_break = True
                break
        if not is_break:
            ret = True
            break

    if ret is True:
        print('YES')
        return

    if bingo[0][0] is True and bingo[1][1] is True and bingo[2][2] is True:
        print('YES')
        return

    if bingo[0][2] is True and bingo[1][1] is True and bingo[2][0] is True:
        print('YES')
        return

    print('NO')


if __name__ == '__main__':
    main()

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] == list1[2]:
        bingo += 1
if list1[3]==list1[4]:
    if list1[4] == list1[5]:
        bingo += 1
if list1[6]==list1[7]:
    if list1[7] == list1[8]:
        bingo += 1
if list1[0]==list1[3]:
    if list1[3] == list1[5]:
        bingo += 1
if list1[1]==list1[4]:
    if list1[4] == list1[7]:
        bingo += 1
if list1[2]==list1[5]:
    if list1[5] == list1[8]:
        bingo += 1
        

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

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