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:

from collections import defaultdict

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

grid = []

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

N = int(input())
nums = set()
nums_freq = defaultdict(int)
for i in range(N):
    n = int(input())
    nums.add(n)
    nums_freq[n] += 1

def is_bingo(nums):
    result = []
    for n in nums:
        if n not in nums:
            return False

    curr_freqs = {}
    for n in nums:
        curr_freqs[n] = nums_freq[n]
    
    for n in nums:
        curr_freqs[n] -= 1
        if curr_freqs[n] < 0:
            return False

    return True

def solve():
    # rows
    for i in range(3):
        if is_bingo(grid[i]):
            return True

    # cols
    for i in range(3):
        curr_col = [grid[i][j] for j in range(3)]
        if is_bingo(curr_col):
            return True

    # downhill diagonal
    downhill = [grid[i][i] for i in range(3)]
    if is_bingo(downhill):
        return  True

    # uphill
    uphill = [grid[3 - 1 - i][i] for i in range(3)]
    if is_bingo(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 _ in range(3) ]
n = int(input())
b = [ int(input()) for _ in range(n) ]

import numpy as np
a = np.array(a)
# print(a)
# print(n)
# print(b)

c = a[1,1]
# print(c)

if c in b:
    for i in range(n):
        if b[i] in a:
            r = np.where(a==b[i])
            a[r[0][0],r[1][0]] = 0
        else:
            pass
else:
    print("No")
    exit()

# print(a)

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

Submission status: Wrong Answer

Solution code:
al = input().split()
bl = input().split()
cl = input().split()
al = [int(i) for i in al]
bl = [int(i) for i in bl]
cl = [int(i) for i in cl]
h1 = [0,0,0]
h2 = [0,0,0]
h3 = [0,0,0]
n = int(input())
for h in range(n):
  m = int(input())
  ac = 0
  bc = 0
  cc = 0
  for i in al:
    if i == m:
      h1[ac] = 1
    ac += 1
  for i in bl:
    if i == m:
      h2[bc] = 1
    bc += 1
  for i in cl:
    if i == m:
      h3[cc] = 1
    cc += 1
if (h1 or h2 or h3) == [1,1,1]:
  print("Yes")
elif h1[0]==1 and h2[0]==1 and h3[0]==1:
  print("Yes")
elif h1[1]==1 and h2[1]==1 and h3[1]==1:
  print("Yes")
elif h1[2]==1 and h2[2]==1 and h3[2]==1:
  print("Yes")
elif h1[0]==1 and h2[1]==1 and h3[2]==1:
  print("Yes")
elif h1[2]==1 and h2[1]==1 and h3[0]==1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys
bingo = [list(map(int, input().split())) for _ in range(3)]
input_num = int(input())
input_list = [int(input()) for _ in range(input_num)]
flag = False
for l in bingo:
	match_count = 0
	if [x for x in l if x in input_list]:
		match_count = len([x for x in l if x in input_list])
		if match_count == 3:
			print('Yes')
			sys.exit()


for l in list(zip(bingo)):
	match_count = 0
	if [x for x in l if x in input_list]:
		match_count = len([x for x in l if x in input_list])
		if match_count == 3:
			print('Yes')
			sys.exit()

match_count = 0
for n, l in zip([0,1,2], bingo):
	if l[n] in input_list:
		match_count += 1
	if match_count == 3:
		print('Yes')
		sys.exit()

match_count = 0
for n, l in zip([-1,-2,-3], bingo):
	if l[n] in input_list:
		match_count += 1
	if match_count == 3:
		print('Yes')
		sys.exit()

print('No')

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

for i in range(3):
    if len(set(A[i])) == 1 and A[i][0] == 0:
        ans = True

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

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

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
aa = list(map(int,input().split()))
aaa = list(map(int,input().split()))
A = []
A.append(a)
A.append(aa)
A.append(aaa)
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))
c = []
ans = 0
if (A[0] in b) or (A[1] in b) or (A[2] in b):
    ans += 1
elif (A[0][0] in b) and (A[1][1] in b) and (A[2][2] in b):
    ans += 1
elif (A[0][2] in b) and (A[1][1] in b) and (A[2][0] in b):
    ans += 1
for i in range(3):
    for j in range(3):
        c.append(A[i][j])
    if c in b:
        ans += 1
if ans == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]
a3 = [int(x) for x in input().split()]
n = int(input())
b = []
for _ in range(n):
    b.append(input())
res = ""
for x in b:
    if int(x) == int(a1[0]):
        print(x)
        res += "1"
    if int(x) == int(a2[1]):
        res += "1"
    if int(x) == int(a3[2]):
        res += "1"
if res == "111":
    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()))
#print(A1,A2,A3)
N = int(input())
for i in range(N):
  a = int(input())
  for j in range(3):
    for A11 in A1:
      if a == A11:
        A1[j] = 0
    for A22 in A2:
      if a == A22:
        A2[j] = 0
    for A33 in A3:
      if a == A33:
        A3[j] = 0
B1= [A1[0], A2[0], A3[0]]
B2= [A1[1], A2[1], A3[1]]
B3= [A1[2], A2[2], A3[2]]
C1= [A1[0], A2[1], A3[2]]
C2= [A1[2], A2[1], A3[0]]
#print(A1, A2, A3, B1, B2, B3, C1, C2)
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0 or sum(B1) == 0 or sum(B2) == 0 or sum(B3) == 0 or sum(C1) == 0 or sum(C1) == 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 = []
for i in range(N):
    b.append(int(input()))
x = False
for i in range(3):
    count = 0
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                count += 1
    if count == 3:
        x = True
        break
if not x:
    for i in range(3):
        count = 0
        for j in range(3):
            for k in range(N):
                if A[j][i] == b[k]:
                    count += 1
        if count == 3:
            x = True
            break
if not x:
    count = 0
    for i in range(3):
        for k in range(N):

            if A[i][i] == b[k]:
                count += 1
    if count == 3:
        x = True
if not x:
    count = 0
    for i in range(3):
        for k in range(N):
            if A[2-i][i] == b[k]:
                count += 1
    if count == 3:
        x = True

if x:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
table = []
for i in range(3):
    table.append(list(map(int, input().split())))
parts = int(input())
p_list = []
for i in range(parts):
    p_list.append(int(input()))

chk = 0
colc = [0, 0, 0]
naname = 0
for r_idx, row in enumerate(table):
    rcnt = 0
    for c_idx, col in enumerate(row):
        if col in p_list:
            rcnt += 1
            colc[c_idx] += 1
            if r_idx == c_idx:
                naname += 1
    if rcnt == 3:
        chk += 1

if len(list(filter(lambda x: x > 0, colc))) > 0:
    chk += 1

if naname == 3:
    chk += 1

print('YES' if chk > 0 else 'NO')

Submission status: Wrong Answer

Solution code:
AA = []

for i in range(3):
    AA.append(input().split())

N = int(input())
for i in range(N):
    bi = input()
    for i in range(3):
        aa = AA[i]
        for a in range(3):
            if bi == aa[a]:
                AA[i][a] = 'B'
            
# yoko
flag = 0
for i in range(3):
    aa = AA[i]
    flag = 1
    for j in range(3):
        if aa[j] != 'B':
            flag = 0 
    if flag == 1:
        break
# tate        
if flag == 0:
    for i in range(3):
        flag = 1
        for j in range(3):
            if AA[j][i] != 'B':
                flag = 0
        if flag == 1:
            break

# naname
if flag == 0:
    flag = 1
    for i in range(3):
        if AA[i][i] != 'B':
            flag = 0
if flag ==0: 
    for i in range(3):
#         print(flag, AA[i][2-i])
        if AA[i][2-i] != 'B':
            flag = 0

# print(AA)
            
if flag == 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))

loopflag = False
if N >= 3:
    for i in range(0, len(result) - 2):
        for j in range(i + 1, len(result) - 1):
            for k in range(j + 1, len(result)):
                if((result[i] + result[j] + result[k]) % 3 == 0):
                    loopflag = True
                    break
    if loopflag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
bingo = []
for _ in range(3):
    row = input().split()
    for i in row:
        bingo.append(int(i))
        
N = int(input())

for i in range(N):
    num = int(input())
    bingo = [0 if b == num else b for b in bingo]

if bingo[0] == 0 and bingo[1] == 0 and bingo[2] == 0:
    print('Yes')
elif bingo[0] == 0 and bingo[3] == 0 and bingo[6] == 0:
    print('Yes')
elif bingo[0] == 0 and bingo[4] == 0 and bingo[8] == 0:
    print('Yes')
elif bingo[2] == 0 and bingo[4] == 0 and bingo[6] == 0:
    print('Yes')
elif bingo[2] == 0 and bingo[5] == 0 and bingo[8] == 0:
    print('Yes')
elif bingo[6] == 0 and bingo[7] == 0 and bingo[8] == 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_list = [int(input()) for _ in range(n)]

for y in range(3):
    for b in b_list:
        if b in a_list[y]:
            index = a_list[y].index(b)
            a_list[y][index] = -1

is_bingo = False
for y in range(3):
    if sum(a_list[y]) == -3:
        is_bingo = True
        break

    y_list = []
    for x in range(3):
        y_list.append(a_list[y][x])
    if len(y_list) == 3 and sum(y_list) == -3:
        is_bingo = True
        break

if a_list[0][0]+a_list[1][1]+a_list[2][2] == -3:
    is_bingo = True
elif a_list[0][2]+a_list[1][1]+a_list[2][0] == -3:
    is_bingo = True


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

Submission status: Wrong Answer

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

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

for i in call:
	if i in a:
		a[a.index(i)] = 0

ans = 'No'

if a[0] == 0:
	if a[1] == 0 and a[2] == 0:
		ans = 'Yes'
	elif a[3] == 0 and a[6] == 0:
		ans = 'Yes'
	elif a[4] == 0 and a[8] == 0:
		ans = 'Yes'
elif a[1] == 0:
	if a[4] == 0 and a[7] == 0:
		ans = 'Yes'
elif a[2] == 0:
	if a[5] == 0 and  a[8] == 0:
		ans = 'Yes'
	elif a[4] == 0 and a[6] == 0:
		ans = 'Yes'
elif a[3] == 0:
	if a[4] == 0 and a[5] == 0:
		ans = 'Yes'
elif a[6] == 0:
	if a[7] == 0 and a[8] == 0:
		ans = 'Yes'
		
print(ans)

Submission status: Wrong Answer

Solution code:
A=[]
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
A.append(list(map(int,input().split())))
n=int(input())
L=[]
for i in range(n):
    L.append(int(input()))
M=[[0,0,0],[0,0,0],[0,0,0]]
for i in L:
    for j in range(3):
        for k in range(3):
            if i==A[j][k]:
                M[j][k]=1

for i in range(3):
    if sum(M[i])==3:
        print("Yes")
        exit()
    elif M[i][0]+M[i][1]+M[i][2]==3:
        print("Yes")
        exit()

if M[0][0]+M[1][1]+M[2][2]==3 or M[0][2]+M[1][1]+M[2][0]==3:
    print("Yes")
    exit()
    
print("No")

Submission status: Wrong Answer

Solution code:
import sys

def main():
    a=[]
    b=[]
    c=[]
    for i in range(3):
        tmp = input().replace('\n','').split(' ')
        tmp = list(map(int, tmp))
        a.append([tmp[0],False])
        a.append([tmp[1],False])
        a.append([tmp[2],False])
        c.append(tmp[0])
        c.append(tmp[1])
        c.append(tmp[2])
    n = int(input().replace('\n',''))
    for i in range(n):
        try:
            tmp = c.index(int(input().replace('\n','')))
            a[tmp][1] = True
        except ValueError:
            pass
    for i in range(3):
        if a[i][1] and a[i+3][1] and a[i+6][1]:
            res = 'Yes'
            break
        elif a[i*3][1] and a[i*3+1][1] and a[i*3+2][1]:
            res = 'Yes'
            break
        elif a[0][1] and a[4][1] and a[7][1] or a[2][1] and a[4][1] and a[6][1]:
            res = 'Yes'
            break
        else:
            res = 'No'
            break
    print(res)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

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 (a12 and a22 and a32 in l) or (a31 and a23 and a33 in l) or (a11 and a22 and a33 in l) or (a31 and a22 and a31 in l):
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
def check(A,b):
    for raw in range(3):
        for colomn in range(3):
            if A[raw][colomn] == b:
                A[raw][colomn] = -1
                return
    return

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
is_bingo = 'No'
for _ in range(N):
    b = int(input())
    check(A,b)

for raw in range(3):
    if A[raw][:].count(-1) == 3:
        is_bingo = 'Yes'

for colomn in range(3):
    if A[:][colomn].count(-1) == 3:
        is_bingo = 'Yes'

if A[0][0] + A[1][1] + A[2][2] == -3:
    is_bingo = 'Yes'
if A[0][2] + A[1][1] + A[2][0] == -3:
    is_bingo = 'Yes'

print(is_bingo)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())

z1=[]
z2=[]
z3=[]
z4=[]
z5=[]
z6=[]
z7=[]
z8=[]
z1.append(a)
z1.append(b)
z1.append(c)
z2.append(d)
z2.append(e)
z2.append(f)
z3.append(g)
z3.append(h)
z3.append(i)
z4.append(a)
z4.append(d)
z4.append(g)
z5.append(b)
z5.append(e)
z5.append(h)
z6.append(c)
z6.append(f)
z6.append(i)
z7.append(a)
z7.append(e)
z7.append(i)
z8.append(c)
z8.append(e)
z8.append(g)

n=int(input())
for i in range(n):
    x=int(input())
    if x in z1:z1.remove(x)
    if x in z2:z2.remove(x)
    if x in z3:z3.remove(x)
    if x in z4:z4.remove(x)
    if x in z5:z5.remove(x)
    if x in z6:z6.remove(x)
    if x in z7:z7.remove(x)
    if x in z8:z8.remove(x)

if len(z1)==3 and len(z2)==3 and len(z3)==3 and len(z4)==3 and len(z5)==3 and len(z6)==3 and len(z7)==3 and len(z8)==3:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

for i in range(N):
    b = int(input())
    for I in range(3):
        for J in range(3):
            if A[I][J] == b:
                A[I][J] = 0

bingo = False
#print(*A, sep='\n')
#print(A[0][:])
#print(A[:][0])
# 横
for i in range(3):
    if A[i][:] == [0, 0, 0]:
        bingo = True
# 縦
for j in range(3):
    if A[:][j] == [0, 0, 0]:
        bingo = True

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

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

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

Submission status: Wrong Answer

Solution code:
gyo1 = list(map(int,input().split()))
gyo2 = list(map(int,input().split()))
gyo3 = list(map(int,input().split()))
 
n = int(input())
for i in range(n):
  detame = int(input())
  if detame in gyo1:
    gyo1[gyo1.index(detame)] = -1
  elif detame in gyo2:
    gyo2[gyo2.index(detame)] = -1
  elif detame in gyo3:
    gyo3[gyo3.index(detame)] = -1
    
if gyo1.count(-1) == 3 or gyo2.count(-1) == 3 or gyo3.count(-1) == 3:
  print('Yes')
  exit()
 
for i in range(2):
  if gyo1[i] == -1 and gyo2[i] == -1 and gyo3[i] == -1 :
    print('Yes')
    exit()
    
if gyo1[0] == -1 and gyo2[1] == -1 and gyo3[2] == -1 : 
  print('Yes')
elif gyo1[2] == -1 and gyo2[1] == -1 and gyo3[0] == -1 : 
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
b = []
b.append([int(s) for s in input().split()])
b.append([int(s) for s in input().split()])
b.append([int(s) for s in input().split()])

n = int(input())

for i in range(0, n):
    v = int(input())

    for i in range(0, 3):
        for j in range(0, 3):
            if b[i][j] == v:
                b[i][j] = 999

ans = 'NO'

for i in range(0, 3):
    s = set(b[i])

    if len(s) == 1:
        ans = 'YES'

for i in range(0, 3):
    s = set([b[0][i], b[1][i], b[2][i]])

    if len(s) == 1:
        ans = 'YES'

c = set([b[0][0], b[1][1], b[2][2]])

if len(c) == 1:
    ans = 'YES'

c = set([b[0][2], b[1][1], b[2][0]])

if len(c) == 1:
    ans = 'YES'

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

import numpy as np
a = np.array(a)
# print(a)
# print(n)
# print(b)

c = a[1,1]
# print(c)

if c in b:
    for i in range(n):
        if b[i] in a:
            r = np.where(a==b[i])
            a[r[0][0],r[1][0]] = 0
        else:
            pass
else:
    print("No")
    exit()

# print(a)

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

Submission status: Wrong Answer

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

#print(bingo)
#print(number)
check=[0,0,0,0,0,0,0,0,0]
ans=0
for i in range(N):
    for j in range(3):
        for k in range(3):
            if number[i][0]==bingo[j][k]:
                check[3*j+k]=1
                
                
                
for i in range(3):
    if check[0+3*i]==check[1+3*i]==check[2+3*i]==1:
        ans=1
    if check[j]==check[j+3]==check[j+6]==1:
        ans=1
        
if check[0]==check[4]==check[8]==1:
    ans=1
if check[2]==check[4]==check[6]==1: 
    ans=1
    
if ans==1:
    print("Yes")
else:
    print("No")
    
#print(check)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())

A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
A = ["x"]*9

N = int(input())
b = []
ans = "No"

for i in range(N):
  b.append(int(input()))
  for j in range(3):
    if(b[i]==A1[j]):
      A[j]="o"
    elif(b[i]==A2[j]):
      A[j+3]="o"
    elif(b[i]==A3[j]):
      A[j+6]="o"

for i in range(3):
  if(A[i]=="o" and A[i+1]=="o" and A[i+2]=="o"):
    ans = "Yes"
  if(A[i]=="o" and A[i+3]=="o" and A[i+6]=="o"):
    ans = "Yes"

if(A[0]=="o" and A[4]=="o" and A[8]=="o"):
  ans = "Yes"
if(A[2]=="o" and A[4]=="o" and A[6]=="o"):
  ans = "Yes"



print(ans)

Submission status: Wrong Answer

Solution code:
#python3

def main():
    a = []
    for _ in range(3):
        x, y, z = map(int, input().split())
        a.append((x, y, z))
    n = int(input())
    b =[]
    for _ in range(n):
        b.append(int(input()))

    g = [[0 for _ in range(3)] for _ in range(3)]
    for i in range(3):
        for j in range(3):
            flag = False
            for k in range(n):
                if a[i][j] == b[k]:
                    flag = True
            if flag:
                g[i][j] = 1


    bingo = False
    for i in range(3):
        flag = True
        if g[i][i] != 1:
            flag = False
        if flag:
            bingo = True            
    

    for i in range(3):
        if sum(g[i]) == 3:
            bingo = True

    if (g[0][0] + g[1][0] + g[2][0]):
        bingo = True
    
    if (g[0][1] + g[1][1] + g[2][1]):
        bingo = True
    
    if (g[0][2] + g[1][2] + g[2][2]):
        bingo = True

    if bingo:
        print('Yes')
    else:
        print('No')
main()

Submission status: Wrong Answer

Solution code:
import sys

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

n = input()
n = int(n)

for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        a[j][k] = 0
        
      if j == 2 and (a[0][k] == 0 and a[1][k] == 0 and a[2][k] == 0):
        print("Yes")
        sys.exit()
      
    if a[j][0] == 0 and a[j][1] == 0 and a[j][2] == 0:
      print("Yes")
      sys.exit()
    
  if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    print("Yes")
    sys.exit()
  
print("No")

Submission status: Wrong Answer

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

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

    ans = [[[] for _ in range(3)] for _ in range(3)]
    for i, A_ in enumerate(A):
        for j, a in enumerate(A_):
            ans[i][j] = a in B
            if a in B:
                N -= 1
            if N == 0:
                break
        if N == 0:
                break

    if (all(ans[0]) or all(ans[1]) or all(ans[1])
        or all([ans[0][0], ans[1][0], ans[2][0]])
        or all([ans[0][1], ans[1][1], ans[2][1]])
        or all([ans[0][2], ans[1][2], ans[2][2]])
        or all([ans[0][0], ans[1][1], ans[2][2]])
        or all([ans[2][0], ans[1][1], ans[0][2]])):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

arr = np.array([a1, a2, a3])
mask = np.zeros_like(arr)

for num in nums:
    idx = np.where(arr == num)

    if len(idx[0]) == 0:
        pass
    else:
        mask[idx] = 1
    print(mask)

s_v = np.sum(mask, axis=0)
s_h = np.sum(mask, axis=0)
s_diag_1 = mask[0, 0] + mask[1, 1] + mask[2, 2]
s_diag_2 = mask[0, 2] + mask[1, 1] + mask[2, 0] 
s = np.maximum(np.concatenate([s_v, s_h, [s_diag_1], [s_diag_2]]) - 2, 0)

if np.max(s) > 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:

l1=list(map(int ,input().split()))
l2=list(map(int ,input().split()))
l3=list(map(int ,input().split()))
l4=[l1[0],l2[1],l3[2]]
l5=[l1[2],l2[1],l3[0]]
n = int(input())
l=[int(input()) for x in range(n)]

if l1[0] and l1[1] and l1[2] in l:
    print("Yes")
elif l2[0] and l2[1] and l2[2] in l:
    print("Yes")
elif l3[0] and l3[1] and l3[2] in l:
    print("Yes")
elif l4[0] and l4[1] and l4[2] in l:
    print("Yes")
elif l5[0] and l5[1] and l5[2] in l:
    print("Yes")
elif l1[0] and l2[0] and l3[0] in l:
    print("Yes")
elif l1[1] and l2[1] and l3[1] in l:
    print("Yes")
elif l1[2] and l2[2] and l3[2] in l:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A1_s = input().split(' ')
A2_s = input().split(' ')
A3_s = input().split(' ')
A1 = []
A2 = []
A3 = []

for i in range(3):
  A1.append(int(A1_s[i]))
  A2.append(int(A2_s[i]))
  A3.append(int(A3_s[i]))

N = int(input())
ans = 0

for i in range(N):
  bi = int(input())

  for j in range(3):
    if bi == A1[j]:
      A1[j] = 1
      break
    elif bi == A2[j]:
      A2[j] = 1
      break
    elif bi == A3[j]:
      A3[j] = 1
      break
    
  P1 = A1[0]*A1[1]*A1[2]
  if P1 == 1:
    ans = 1
    break
  P2 = A2[0]*A2[1]*A2[2]
  if P2 == 1:
    ans = 1
    break
  P3 = A3[0]*A3[1]*A3[2]
  if P3 == 1:
    ans = 1
    break
  P4 = A1[0]*A2[0]*A3[0]
  if P4 == 1:
    ans = 1
    break
  P5 = A1[1]*A2[1]*A3[1]
  if P5 == 1:
    ans = 1
    break
  P6 = A1[2]*A2[2]*A3[2]
  if P6 == 1:
    ans = 1
    break
  P7 = A1[0]*A2[1]*A3[2]
  if P7 == 1:
    ans = 1
    break
  P8 = A1[2]*A2[2]*A3[0]
  if P8 == 1:
    ans = 1
    break
    

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

Submission status: Wrong Answer

Solution code:
import sys
a = []
for i in range(3):
    a += list(map(int, input().split()))
n = int(input())
b = [int(input()) for i in range(n)]
answer = [False for i in range(9)]

for po in b:
    for i in range(9):
        if a[i] == po:
            answer[i] = True


for i in range(3):
    if answer[0+3*i] and answer[1+3*i] and answer[2+3*i]:
        print("Yes")
        sys.exit()
    elif answer[0 + i] and answer[1 + i] and answer[2 + i]:
        print("Yes")
        sys.exit()
if answer[0] and answer[4] and answer[8]:
    print("Yes")
elif answer[2] and answer[4] and answer[6]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

ans = 'No'
for a in aa:
    if a >= 3:
        ans = "Yes"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))

loopflag = False
if len(result) >= 3:
    for i in range(0, len(result) - 2):
        for j in range(i + 1, len(result) - 1):
            for k in range(j + 1, len(result)):
                if((i + j + k) % 3 == 0):
                    loopflag = True
                    break
    if loopflag:
        print('Yes')
    else:
        print('No')
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()))

N = int(input())

s = [int(input()) for i in range(N)]


if len(list(set(a) & set(s))) or len(list(set(b) & set(s))) or len(list(set(c) & set(s))) == 3:
    print('Yes')

elif len(list(set([a[0],b[1],c[2]]) & set(s))) or len(list(set([a[2],b[1],c[0]]) & set(s))) == 3:
    print('Yes')

elif len(list(set([a[0],b[0],c[0]]) & set(s))) or len(list(set([a[1],b[1],c[1]]) & set(s))) or len(list(set([a[2],b[2],c[2]]) & set(s))) == 3:
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
b=[int(input()) for _ in range(int(input()))]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
ans="No"            
for i in a:
    if a[0]==a[1]==a[2]==0:
        ans="Yes"
for i in range(3):
    if a[0][i]==a[1][i]==a[2][i]==0:
        ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:
    ans="Yes"
if a[0][2]==a[1][1]==a[2][0]==0:
    ans="Yes"
print(ans)

Submission status: Wrong Answer

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

if N < 3:
    print("No")
    exit()

for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0

yes = False

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


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

Submission status: Wrong Answer

Solution code:
import numpy as np


a = []

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


a = np.array(a)

#print(a)

n = int(input())

for i in range(n):
    b = int(input())
    for j in a:
        for k in j:
            if (k == b):
                k = 0
                break

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

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

Submission status: Wrong Answer

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

n = int(input())

for i in range(n):
  tmp = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == tmp:
        b[j][k] = 1
        if b[j][0]==1 and b[j][1]==1 and b[j][2]==1:
          print('Yes')
          exit()
        elif b[0][k]==1 and b[1][k]==1 and b[2][k] ==1:
          print('Yes')
          exit()
        elif b[0][0]==1 and b[1][1]==1 and b[2][2] ==1:
          print('Yes')
          exit()
        elif b[0][2]==1 and b[1][1]==1 and b[2][0] ==1:
          print('Yes')
          exit()
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 ([0,1,2]<=ans)or([3,4,5]<=ans)or([6,7,8]<=ans)or([0,3,6]<=ans)or([1,4,7]<=ans)or([2,5,8]<=ans)or([0,4,8]<=ans)or([2,4,6]<=ans):
  print('Yes')
else:
  print('No')