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:

b = []
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
b.append(a1)
b.append(a2)
b.append(a3)
n = int(input())
c = [int(input()) for i in range(n)]
a = []
d = [[0 for i in range(3)] for j in range(3)]
for i in c:
	for j in range(3):
		for k in range(3):
			if b[j][k] == i:
				d[j][k] = 1
	#print (d)
	if d[0][0] == 1 and d[1][1] == 1 and d[2][2] == 1:
		print ("Yes")
		exit()
	if d[0][2] == 1 and d[1][1] == 1 and d[2][0] == 1:
		print ("Yes")
		exit()
	if d[0][0] == 1 and d[0][1] == 1 and d[0][2] == 1:
		print ("Yes")
		exit()
	if d[1][0] == 1 and d[1][1] == 1 and d[1][2] == 1:
		print ("Yes")
		exit()
	if d[2][0] == 1 and d[2][1] == 1 and d[2][2] == 1:
		print ("Yes")
		exit()
	if d[0][0] == 1 and d[0][1] == 1 and d[0][2] == 1:
		print ("Yes")
		exit()
	if d[1][0] == 1 and d[1][1] == 1 and d[1][2] == 1:
		print ("Yes")
		exit()
	if d[2][0] == 1 and d[2][1] == 1 and d[2][2] == 1:
		print ("Yes")
		exit()
print ("No")

Submission status: Wrong Answer

Solution code:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))

n = int(input())
b = list(int(input()) for i in range(n))

if a1[0] in b and a2[0] in b and a3[0] in b:
    print('Yes')
elif a1[1] in b and a2[1] in b and a3[1] in b:
    print('Yes')
elif a1[2] in b and a2[2] in b and a3[2] in b:
    print('Yes')
elif a1[0] in b and a2[1] in b and a3[2] in b:
    print('Yes')
elif a1[2] in b and a2[1] in b and a3[0] in b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

c = [[0,0,0]]*3

ans = False

for v in b:
    for i in range(3):
        for j in range(3):
            if v==a[i][j]:c[i][j]=1
    for k in range(3):
        if sum(c[i])==3:
            ans = True
            break
        if (c[0][i]+c[1][i]+c[2][i])==3:
            ans = True
            break
        if (c[0][0]+c[1][1]+c[2][2])==3:
            ans = True
            break
        if (c[0][2]+c[1][1]+c[2][0])==3:
            ans = True
            break
    if ans:break
if ans:print('Yes')
else:print('No')

Submission status: Wrong Answer

Solution code:
A = tuple([tuple(map(int,input().split())) for i in range(3)])
N = int(input())
B = tuple([int(input()) for i in range(N)])
BINGO = [[False]*3]*3
for b in B:
    for y, line in enumerate(A):
        for x, a in enumerate(line):
            if a == b:
                BINGO[y][x] = True
def solve():
    for line in BINGO:
        if line == [True, True, True]:
            return "Yes"
    if BINGO[0][0] == True and BINGO[1][0] == True and BINGO[2][0] == True:
        return "Yes"
    if BINGO[0][1] == True and BINGO[1][1] == True and BINGO[2][1] == True:
        return "Yes"
    if BINGO[0][2] == True and BINGO[1][2] == True and BINGO[2][2] == True:
        return "Yes"
    if BINGO[0][0] == True and BINGO[1][1] == True and BINGO[2][2] == True:
        return "Yes"
    if BINGO[0][2] == True and BINGO[1][1] == True and BINGO[2][0] == True:
        return "Yes"
    return 'No'        
print(solve())

Submission status: Wrong Answer

Solution code:
import sys

matrix = []
for i in range(3):
  matrix.append([int(j) for j in input().split()])
print(matrix)

def find(b):
  for i in range(3):
    for j in range(3):
      if matrix[i][j] == b:
        return (i, j)
  return None

matched = [[False for _ in range(3)]
           for _ in range(3)]
n = int(input())
for i in range(n):
  b = int(input())
  result = find(b)
  if result is not None:
    matched[result[0]][result[1]] = True
    
for i in range(3):
  ans = True
  for j in range(3):
    if not matched[i][j]:
      ans = False
      break
  if ans:
    print('Yes')
    sys.exit(0)
  
for i in range(3):
  ans = True
  for j in range(3):
    if not matched[j][i]:
      ans = False
      break
  if ans:
    print('Yes')
    sys.exit(0)
  
if matched[0][0] and matched[1][1] and matched[1][1]:
  print('Yes')
  sys.exit(0)

if matched[0][2] and matched[1][1] and matched[2][0]:
  print('Yes')
  sys.exit(0)
  
print('No')

Submission status: Wrong Answer

Solution code:
def main():
    A = []
    A.append(list(map(int, input().split(' '))))
    A.append(list(map(int, input().split(' '))))
    A.append(list(map(int, input().split(' '))))

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

    Af = []
    for i in range(3):
        for j in range(3):
            if A[i][j] in b:
                A[i][j] = 0
            Af.append(A[i][j])
    
    bingo_list = [[0,1,2],[0,4,8],[0,3,6],[2,4,7],[1,4,7],[2,5,8],[3,4,5],[6,7,8]]

    ans = False
    for bingo in bingo_list:
        _sum = 0
        for i in bingo:
            _sum += Af[i]
            if _sum == 0:
                ans = True
    
    if ans:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if int(a[i][j]) in b:
            a[i][j]=999
#印をつける
c=0
for i in range(3):
    if a[i][0]==999 and a[i][1]==999 and a[i][2]==999:
        c+=1
    elif a[0][i]==999 and a[1][i]==999 and a[2][i]==999:
        c+=1
    elif a[i][i]==999:
        c+=1
    elif a[0][2]==999 and a[2][2]==999 and a[2][0]==999:
        c+=1
if c==0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

ans = [[0,0,0] for i in range(3)]
ans1 = [[0,0,0] for i in range(3)]

res = False

for i in range(n):
    for a in range(3):
        for c in range(3):
            if b[i] == List[a][c]:
                ans[a][c] = 1
                ans1[c][a] = 1

if ans[1][1] == 1:
    if ans[1][0] > 0 and ans[2][2] > 0:
        res = True
    if ans[2][0] > 0 and ans[1][2] > 0:
        res = True
                
for i in range(3):
    if ans[i][0] > 0 and ans[i][1] > 0 and ans[i][2] > 0:
        res = True
    if ans1[i][0] > 0 and ans1[i][1] > 0 and ans1[i][2] > 0:
        res = True
            
if res:
    print('Yes')
else:
    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]"):
    for i in range(N):
        searchAndPut(A,b[i])

    if A[0][0] == -1:
        if A[0][1] == A[0][2] == -1:
            print(YES)
        elif A[1][0] == A[2][0] == -1:
            print(YES)
        elif A[1][1] == A[2][2] == -1:
            print(YES)
    elif A[0][1] == -1:
        if A[1][1] == A[2][1] == -1:
            print(YES)
    elif A[0][2] == -1:
        if A[1][2] == A[2][2] == -1:
            print(YES)
        elif A[1][1] == A[2][0] == -1:
            print(YES)
    elif A[1][0] == -1:
        if A[1][1] == A[1][2] == -1:
            print(YES)
    elif A[2][0] == -1:
        if A[2][1] == A[2][2] == -1:
            print(YES)
    else:
        print(NO)
    


def searchAndPut(A: "List[List[int]]",b):
    for i in range(3):
        list = A[i]
        if (b in list):
            list[list.index(b)] = -1
            break

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:
a = [list(map(int, input().split())) for i in range(3)]
aa = list(zip(*a))
n = int(input())
b = [int(input()) for _ in range(n)]
if a[0] in b or a[1] in b or a[2] in b or aa[0] in b or aa[1] in b or aa[2] in b or (a[0][0] in b and a[1][1] in b and a[2][2] in b) or (a[0][2] in b and a[1][1] in b and a[2][0] in b):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a11,a12,a13 = input().split()
a21,a22,a23 = input().split()
a31,a32,a33 = input().split()
lst = [a11,a12,a13,a21,a22,a23,a31,a32,a33]
bingo = []
n = int(input())
for i in range(n):
    ai = input()
    if ai in lst:
        bingo.append(lst.index(ai))
if 4 in bingo:
    if (0 and 8) in bingo:
        print('Yes')
        exit()
    if (1 and 7) in bingo:
        print('Yes')
        exit()
    if (2 and 6) in bingo:
        print('Yes')
        exit()
    if (3 and 5) in bingo:
        print('Yes')
        exit()
if 0 in bingo:
    if (1 and 2) in bingo:
        print('Yes')
        exit()
    if (3 and 6) in bingo:
        print('Yes')
        exit()
if 8 in bingo:
    if (2 and 5) in bingo:
        print('Yes')
        exit()
    if (6 and 7) in bingo:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
As = []
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))

cs = [[0,0,0], [0,0,0],[0,0,0]]
pos_dic = {}
for i,x in enumerate(As):
  for j,xx in enumerate(x):
    pos_dic[xx] = (i,j)
    
def check(cs):
  for i in range(3):
    if sum(cs[i]) == 3:
      return True
    if (cs[i][0] + cs[i][1] + cs[i][2]) == 3:
      return True
  if (cs[2][2] + cs[1][1] + cs[0][0]) == 3:
    return True
  if (cs[2][0] + cs[1][1] + cs[0][2]) == 3:
    return True
  return False
    

flag = 0
N = int(input())
for i in range(N):
  x = int(input())
  if x in pos_dic:
    i,j = pos_dic[x]
    cs[i][j] = 1
    if check(cs):
      flag = 1
      break
if flag == 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def a():
    A = []
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[int(input())] = 1

    B = list(map(lambda x:d[x],A))

    if B[5]:
        if B[0] * B[8] + B[2] * B[6]:
            return 1
    
    for i in range(3):
        if sum(B[i*3:i*3+3]) == 3:
            return 1
        if sum(B[i::2]) == 3:
            return 1
    
    return 0

print(["No","Yes"][a()])

Submission status: Wrong Answer

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

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

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

ans = False
for i in range(3):
    if A[i] == [0, 0, 0]:
        ans = True

    cnt = 0
    for j in range(3):
        if A[i][j] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

if A[0][0] == A[1][1] == A[2][2] == 0:
    ans = True
if A[0][2] == A[1][1] == A[2][0] == 0:
    ans = True

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

Submission status: Wrong Answer

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

def check(line, num_set):
  for num in line:
    if(not(num in num_set)):
      return False
  return True

if (check([A[0][0], A[1][0], A[2][0]], B)
    or check([A[0][1], A[1][1], A[2][1]], B)
    or check([A[0][2], A[1][2], A[2][2]], B)
    or check([A[0][0], A[1][0], A[2][0]], B)
    or check([A[0][1], A[1][1], A[2][1]], B)
    or check([A[0][2], A[1][2], A[2][2]], B)
    or check([A[0][0], A[1][1], A[2][2]], B) or
    check([A[2][0], A[1][1], A[0][2]], B)):
  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= [int(input()) for i in range(N)]
ans = 0
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
                
sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[i][j]
    if sum == 0:
        print('Yes')
        break

sum = 0
for i in range(3):
    sum=0
    for j in range(3):
        sum=sum+A[j][i]
    if sum == 0:
        print('Yes')
        break

sum = 0
for j in range(3):
    sum=sum+A[i][i]
if sum == 0:
    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)))==3 or sum(list(map(lambda x: x[1], c)))==3 or sum(list(map(lambda x: x[2], c)))==3:
    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')

print(sum(list(map(lambda x: x[0], c))))

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] and dic[k] not in ansl:
        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:
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()

bingo = True

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:
cd = []
for i in range(3):
  p = input().split(" ")
  p = [int(j) for j in p]
  cd.append(p)

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

for i in range(n):
  p = input()
  for j in range(3):
    if int(p) in cd[j]:
      tf.append([j, cd[j].index(int(p))])

id0 = [i[0] for i in tf]
id1 = [i[1] for i in tf]
df = [i[0] - i[1] for i in tf]
sm = [i[0] + i[1] for i in tf]

if id0.count(0) == 3:
  print("Yes")
elif id0.count(1) == 3:
  print("Yes")
elif id0.count(2) == 3:
  print("Yes")
elif id1.count(0) == 3:
  print("Yes")
elif id1.count(1) == 3:
  print("Yes")
elif id1.count(2) == 3:
  print("Yes")
elif df.count(0) == 3:
  print("Yes")
elif sm.count(4) == 3:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
mat = [list(map(int, input().split())) for _ in range(3)]
d = {}
for idx, i in enumerate(mat):
    for idx2, j in enumerate(i):
        d[j] = [idx, idx2]

n = int(input())
mat2 = [[0]*3 for _ in range(3)]

for _ in range(n):
    b = int(input())
    if d.get(b) is None:
        pass
    else:
        i, j = d.get(b)
        mat2[i][j] = 1
        if sum([mat2[i][di] for di in range(3)])== 3:
            print('Yes')
            exit()
        
        if sum([mat2[di][j] for di in range(3)])== 3:
            print('Yes')
            exit()
        
        if sum([mat2[di][di] for di in range(3)])==3:
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
A = [list(map(int, input().split())) for i in range(0,3)]
N = int(input())
b_list =list([int(input()) for i in range(0,N)])
count = 0
for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b_list:
            count = count + (i+1)*(j+1)
if count % 3 == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = {int(input()) for _ in range(n)}
mark = [[False, False, False]]*3

for i in range(3):
    for j in range(3):
        if a[i][j] in b: mark[i][j] = True
ans = 'No'
for i in range(3):
    if all(mark[i]):
        ans = 'Yes'
        break

if ans != 'Yes':
    for j in range(3):
        if mark[0][j] and mark[1][j] and mark[2][j]:
            ans = 'Yes'
            break

if ans != 'Yes':
    if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
grid = []
for _ in range(3):
    array = list(map(int, input().strip().split()))
    grid.append(array)

def judge():
    for i in range(3):
        if grid[i][0] == 0 and grid[i][1] == 0 and grid[i][2]:
            return True
    if grid[0][0] == 0 and grid[1][1] == 0 and grid[2][2] == 0:
        return True
    if grid[0][2] == 0 and grid[1][1] == 0 and grid[2][0] == 0:
        return True
    return False

n = int(input())
ans = "No"
for _ in range(n):
    b = int(input())
    for i in range(3):
        if b in grid[i]:
            grid[i][grid[i].index(b)] = 0
    if judge():
        ans = "Yes"
    print (grid)

print (ans)

Submission status: Wrong Answer

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

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

ans="No"

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

bingo = []

for _ in range(3):
    array = list(map(int, input().split()))
    bingo.append(array)

bingo = list(itertools.chain.from_iterable(bingo))

bingo_bi = [False for _ in range(9)]

n = int(input())

nums = []

for _ in range(n):
    num = int(input())
    if num in bingo:
        bingo_bi[bingo.index(num)] = True

correct = [True, True, True]

if bingo_bi[0:2] == correct and bingo_bi[3:5] == correct and bingo_bi[6:8] == correct:
    print('Yes')
elif bingo_bi[0::3] == correct and bingo_bi[1::3] == correct and bingo_bi[2::3] == correct:
    print('Yes')
elif bingo_bi[0] == True and bingo_bi[4] == True and bingo_bi[8] == True:
    print('Yes')
elif bingo_bi[2::2] == correct:
    print('Yes')
else:
    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 or a21 and a22 and a23 in l or a31 and a32 and a33 in l or a11 and a21 and a31 in l or a22 and a12 and a32 in l or a13 and a23 and a33 in l or a11 and a22 and a33 in l or  a13 and a22 and a31 in l:
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
bingo = list(map(int, input().split()))
bingo.extend(list(map(int, input().split())))
bingo.extend(list(map(int, input().split())))

N = int(input())

res = "No"

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

  for (index, value) in enumerate(bingo):
    if value == num:
      bingo[index] = 0


## 斜め判定
if bingo[0] == bingo[4] == bingo[8] == 0:
  res = "Yes"

else:
  ## 縦横判定
  for i in range(3):
    if (bingo[i] == bingo[i+3] == bingo[i+6] == 0 or bingo[3 * i] == bingo[3 * i + 1] == bingo[3 * i + 2] == 0):
      res = "Yes"
      break
  
print(res)

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j] = 0
if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0 or A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0 or A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0 or A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0 or A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0 or A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0 or A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0 or A[0][2] == 0 and A[1][1] == 0 and A[0][2] == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

c = [[0,0,0]]*3

ans = False

for v in b:
    for i in range(3):
        for j in range(3):
            if v==a[i][j]:c[i][j]=1
    for k in range(3):
        if sum(c[i])==3:
            ans = True
            break
        if (c[0][i]+c[1][i]+c[2][i])==3:
            ans = True
            break
        if (c[0][0]+c[1][1]+c[2][2])==3:
            ans = True
            break
    if ans:break
if ans:print('Yes')
else:print('No')

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

x = []
y = []
for i in range(N):
  if b[i] in A1:
    A1[A1.index(b[i])] = 0
  elif b[i] in A2:
    A2[A2.index(b[i])] = 0
  elif b[i] in A3:
    A3[A3.index(b[i])] = 0

if A1[0] == 0 and A1[0] == A2[0] == A3[0]:
  ans = "Yes"
elif A1[1] == 0 and A1[1] == A2[1] == A3[1]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[2] == A3[2]:
  ans = "Yes"
elif A1[0] == 0 and A1[0] == A2[1] == A3[2]:
  ans = "Yes"
elif A1[2] == 0 and A1[2] == A2[1] == A3[0]:
  ans = "Yes"
else:
  ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
# ABC 157 B
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nms = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
a=[list(map(int, input().split())) for i in range(3)]
n=int(input())
b=[]
for i in range(n):
    bb=int(input())
    b.append(bb)

mat=[[0]*3 for _ in range(3)]

for bb in b:
    for i in range(3):
        for j in range(3):
            if bb==a[i][j]:
                mat[i][j]=1
# print(a)
# print(b)
# print(mat)
for mm in mat:
    if sum(mm)==3:
        print('Yes')
        exit()
a1=mat[0][0]+mat[0][1]+mat[0][2]
a2=mat[1][0]+mat[1][1]+mat[1][2]
a3=mat[2][0]+mat[2][1]+mat[2][2]
a4=mat[0][0]+mat[1][1]+mat[2][2]
a5=mat[0][2]+mat[1][1]+mat[2][0]
if a1==3 or a2==3 or a3==3 or a4==3 or a5==3:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:
t = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
m = [int(input()) for i in range(n)]
for i in range(3):
        if t[i][0] in m and t[i][1] in m and t[i][2] in m:
            print('Yes')
            break
        elif t[0][i] in m and t[1][i] in m and t[2][i] in m:
            print('Yes')
            break
        elif t[0][0] in m and t[1][1] in m and t[2][2] in m:
            print('Yes')
            break
        elif t[0][2] in m and t[1][1] in m and t[2][0] in m:
            print('Yes')
            break
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
D  = [list(map(int, s.split())) for s in open(0)]
bingo = D[0:3]
num = [d[0] for d in D[4:]]
d_col = defaultdict(int)
d_row = defaultdict(int)
d_cross1 =  defaultdict(int)
d_cross2 =  defaultdict(int)
for i in range(len(bingo)):
    for j in range(len(bingo[i])):
        if bingo[i][j] in num:
            d_row[i] += 1 
            d_col[j] += 1 
            if i == j:
                d_cross1[i] += 1 
            if (i, j) in [(0, 2), (1, 1), (2, 0)]:
                d_cross2[i] += 1
flag = 0        
if len(d_row) == 3: 
        flag += 1
if len(d_col) == 3: 
        flag += 1
if len(d_cross1) == 3: 
        flag += 1
if len(d_cross2) == 3: 
        flag += 1
        
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

N = int(input())

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

N=int(input())

for i in range(0,N,1):
    d = int(input())
    for j in range(0,2,1):
        if (a[j]==d):
            a[j]=-1
        if (b[j]==d):
            b[j]=-1
        if (c[j]==d):
            c[j]=-1

flg=0

if(a[0]==-1 and a[1]==-1 and a[2]==-1):
    flg=1
elif(b[0]==-1 and b[1]==-1 and b[2]==-1):
    flg=1
elif(c[0]==-1 and c[1]==-1 and c[2]==-1):
    flg=1

for i in range(3):
    if(a[i]==-1 and b[i]==-1 and c[i]==-1):
        flg=1
if(a[0]==-1 and b[1]==-1 and c[2]==-1):
    flg=1
elif(a[2]==-1 and b[1]==-1 and c[0]==-1):
    flg=1

if (flg==1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
arr = []
ans = []
for i in range(3):
  arr.extend(list(map(int,input().split())))
N = int(input())
for i in range(N):
  num = int(input())
  if num in arr:
    ans.append(arr.index(num))
if (ans<=[0,1,2]) or (ans<=[3,4,5])or (ans<=[6,7,8])or (ans<=[0,3,6])or (ans<=[1,4,7])or (ans<=[2,5,8])or (ans<=[0,4,8])or (ans<=[2,4,6]):
  print('Yes')
else:
  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()))
board = [a, b, c]

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

result = [[False] * 3, [False] * 3, [False] * 3]


for x in l:
  for i in range(3):
    for j in range(3):
      if x == board[i][j]:
        result[i][j] = True
        
ans = False

for i in result:
  if all(i):
    ans = True

for i in range(3):
  if result[i][0] and result[i][1] and result[i][2]:
    ans = True
    break

if result[1][1]:
  if result[0][0] and result[2][2]:
    ans = True
  if result[0][2] and result[2][0]:
    ans = True

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

Submission status: Wrong Answer

Solution code:
a=[[] for i in range(3)]
a[0]=list(map(int,input().split()))
a[1]=list(map(int,input().split()))
a[2]=list(map(int,input().split()))
dic={}
for i in range(3):
    for j in range(3):
        dic[a[i][j]]=0
n=int(input())
for i in range(n):
    b=int(input())
    if b in dic:
        dic[b]=1

def ans():
    for i in range(3):
        for j in range(3):
            #yoko
            y=0
            
            #tate
            t=0
            
            if dic[a[i][j]]:
                y+=1
                
            if dic[a[j][i]]:
                t+=1
        if y==3 or t==3:
            print("Yes")
            return
    if dic[a[0][0]]+dic[a[1][1]]+dic[a[2][2]]==3 or dic[a[0][2]]+dic[a[1][1]]+dic[a[2][0]]==3:
        print("Yes")
        return
    print("No")
    
ans()

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
list1 = a+b+c
bingo = 0
if list1[0]==list1[1]:
    if list1[1] == 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[6]:
        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")

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
n = int(input())

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

okp = [(0,1,2), (3,4,5), (6,7,8) ,(0,3,6), (1,3,7), (2,4,8), (0,4,8), (2,4,6)]
f = "No"
for x, y, z in okp:
    if x in ins and y in ins and z in ins:
        f = "Yes"
        break

print(f)

Submission status: Wrong Answer

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