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,b,c =map(int,input().split())
d,e,f =map(int,input().split())
g,h,i =map(int,input().split())
N=input()
N= int(N)
z = [ input() for i in range(N)]
z =map(int,z)
if a and b and g in z or b and e and h in z or c and f and i in z or a and b and c in z or c and e and f in z or g and h and i in z or a and e and i in z or g and e and c in z:
  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()))
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
result.sort()
print(result)
if N >= 3:
    for i in range(len(result)):
        for j in range(len(result)):
            for k in range(len(result)):
                if (i==j or j==k or k==i):
                    continue 
                if((result[i] % 3 == result[j] % 3 == result[k] % 3 ) or (result[i] // 3 == result[j] // 3 == result[k] // 3) or (result[i] == 0 and result[j] == 4 and result[k] ==8 ) or (result[i] == 2 and result[j]  == 4 and result[k] == 6 )):
                    loopflag = True
    if loopflag:
        print('Yes')
    else:
        print('No')
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 i in range(n)]

aa = []
aa.append(a1)
aa.append(a2)
aa.append(a3)

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

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

Submission status: Wrong Answer

Solution code:
inputgrid1 = input().split(" ")
inputgrid2 = input().split(" ")
inputgrid3 = input().split(" ")
num = int(input())
bingolist = list()
length = 0
check = 0
for i in range (0, num):
    inputnum = int(input())
    if inputnum >= 1 and inputnum <= 100:
        inputnum = str(inputnum)
        bingolist.append(inputnum)
    else:
        break
inputlist = list()
for i in inputgrid1:
    inputlist.append(i)
for i in inputgrid2:
    inputlist.append(i)
for i in inputgrid3:
    inputlist.append(i)
length = len(inputlist) + num
for i in inputlist:
    i = int(i)
    if i >= 1 and i <= 100:
        check = 0
    else:
        check = 1
        break
con1 = inputgrid1[0] == inputgrid2[1]
con2 = num >= 1 and num <= 10
for i in bingolist:
    inputlist.append(i)
inputlist = set(inputlist)
if con1 == False and con2 == True:
    if len(inputlist) == length:
        print("No")
    else:
        print("Yes")
else:
    print()

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 i in range(N)]

flag = True
for i in range(3):
    if (A1 in B) or (A2 in B) or (A3 in B):
        print('Yes')
        flag = False
        break
    elif ((A1[i] in B) and (A2[i] in B)) and (A3[i] in B):
        print('Yes')
        flag = False
        break 
    elif ((A1[0] in B) and (A2[1] in B)) and (A3[2] in B):
        print('Yes')
        flag = False
        break 
    elif ((A1[2] in B) and (A2[1] in B)) and (A3[0] in B):
        print('Yes')
        flag = False
        break 
if flag == True:
    print('No')

Submission status: Wrong Answer

Solution code:
up = list(input().split())
mid = list(input().split())
down = list(input().split())

table = [up, mid, down]
# print(table)
nums = []
while True:
    try:
        nums.append(input())
    except EOFError:
        break
# print(nums)

for i in range(3):
  for j in range(3):
    if table[i][j] in nums:
      table[i][j] = 'T'

flag = False
# yoko check
for i in range(3):
  if table[i].count('T') == 3:
    print('YES')
    flag = True

# tate check
if flag == False:
  if table[0][0]=='T' and table[0][1]=='T' and table[0][2]=='T':
    print('YES')
    flag = True
    
if flag == False:
  if table[1][0]=='T' and table[1][1]=='T' and table[1][2]=='T':
    print('YES')
    flag = True
    
if flag == False:
  if table[2][0]=='T' and table[2][1]=='T' and table[2][2]=='T':
    print('YES')
    flag = True

# naname check
if flag == False:
  if table[0][0]=='T' and table[1][1]=='T' and table[2][2]=='T':
    print('YES')
    flag = True
    
if flag == False:
  if table[0][2]=='T' and table[1][1]=='T' and table[2][0]=='T':
    print('YES')
    flag = True
    
if flag == False:
  print('NO')

Submission status: Wrong Answer

Solution code:
import sys

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

row = A
column = [[] for _ in range(3)]
for i in range(3):
    column[i] = [A[0][i], A[1][i], A[2][i]]
cross = [[A[0][0], A[1][1], A[2][2]], [A[2][0], A[1][1], A[0][2]]]

for i in range(3):
    if row[i] <= B or column[i] <= B:
        print('Yes')
        sys.exit()

for i in range(2):
    if cross[i] <= B:
        print('Yes')
        sys.exit()
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = []
check = []
for i in range(3):
    a.append([int(j) for j in input().split()])

d1 = [a[0][0],a[1][1], a[2][2]]
d2 = [a[0][2],a[1][1], a[2][0]]
col1 = [a[0][0],a[0][1], a[0][2]]
col2 = [a[1][0],a[1][1], a[1][2]]
col3 = [a[2][0],a[2][1], a[2][2]]

n = input()
n = int(n)
for i in range(n):
    check.append(int(input()))


if any(elem in check for elem in d1):
    print("Yes")
elif any(elem in check for elem in d2):
    print("Yes")
elif any(elem in check for elem in col1):
    print("Yes")
elif any(elem in check for elem in col2):
    print("Yes")
elif any(elem in check for elem in col3):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
bingo = [[],[],[]]
 
for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
    sys.exit()
  else:
    print("No")
    sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def func(a, i):
    return {a[0]:i, a[1]:i+1, a[2]:i+2}
A = {}
for i in range(3):
    A.update(func(input().split(), 3*i))
N = int(input())
b = [A.get(input(), -1) for _ in range(N)]
bingo = [[0, 1, 2], [3, 4, 5], [6, 7, 8],
         [0, 3, 6], [1, 4, 7], [2, 5, 8],
         [0, 4, 8], [2, 5, 6]]
for i in bingo:
    if set(i) <= set(b):
        print("Yes")
        break
else:
    print("No")

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())
n = int(input())
num =[]
for j in range(n):
    num.append(int(input()))
if a and d and g in num:
    print('Yes')
elif b and e and h in num:
    print('Yes')
elif c and f and i in num:
    print('Yes')
elif a and b and c in num:
    print('Yes')
elif d and e and f in num:
    print('Yes')
elif g and h and i in num:
    print('Yes')
elif a and e and i in num:
    print('Yes')
elif c and e and g in num:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
import re, sys

A = np.zeros((3,3), dtype=int)
for i in range(3):
  row = input()
  nums = re.split(' ', row)
  for j in range(3):
  	A[i, j] = int(nums[j])
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
for i in range(3):
  if len(set(A[i]) & set(b)) == 3 | len(set(A[:,i]) & set(b)) == 3:
    print('Yes')
    sys.exit()
cross1 = [A[0,0] ,A[1,1], A[2,2]]
cross2 = [A[0,2] ,A[1,1], A[2,0]]
if len(set(cross1) & set(b)) == 3 | len(set(cross2) & set(b)) == 3:
  print('Yes')
  sys.exit()
else:
  print('No')

Submission status: Wrong Answer

Solution code:
row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
num=int(input())
list=[int(input()) for i in range(num)]

for n in list:
  row1 = [0 if i == n else i for i in row1]
  row2 = [0 if i == n else i for i in row2]
  row3 = [0 if i == n else i for i in row3]

# 横
if row1.count(0) == 3 or row2.count(0) == 3 or row3.count(0) == 3:
  print('Yes')

# 縦
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')

# ななめ
elif row2[1] == 0:
  if row1[0] == 0 and row3[2] == 0:
    print('Yes')
  elif row1[2] == 0 and row3[0] == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

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

    n = int(input())

    b = [None]*n
    for i in range(n):
        b[i] = int(input())
    
    #print(a)
    #print(b)

    check = [[False for i in range(3)] for j in range(3)]
    #print(check)
    for i in range(3):
        for j in range(3):
            #print(id(check[i][j]))
            if a[i][j] in b:
              #print("a{}{}={} in b".format(i,j,a[i][j]))
              check[i][j] = True
    #print(check)


    for i in range(3):
        if check[i] == [True]*3:
            print("Yes")
            return
        if [row[i] for row in a] == [True]*3:
            print("Yes")
            return

    if [check[0][0],check[1][1],check[2][2]] == [True]*3:
        print("Yes")
        return
    if [check[0][2],check[1][1],check[2][0]] == [True]*3:
        print("Yes")
        return
    print("No")

main()

Submission status: Wrong Answer

Solution code:
import numpy
a = input().split()
b = input().split()
c = input().split()


A = numpy.array((a,b,c), dtype=int)
A.shape = (3, 3)

N = int(input())
counter = 0
while N > 0:
    B = int(input())
    for i in range(3):
        for j in range(3):
            if B == A[i][j]: 
                counter += 1
    N -= 1
if counter > 0:
    print("Yes")
else: 
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = []
FLAGS = True
for i in range(3):
  N1 = list(map(int, input().split(' ')))
  N.append(N1)

N = np.array(N)

M = int(input())

for i in range(M):
  a = int(input())
  
  for j in range(3):
    for k in range(3):
      if N[j, k] == a:
        N[j, k] = 0


  if (np.all(N == 0, axis = 0).any(0)) or (np.all(N == 0, axis = 1).any(0)) or (np.all(np.diag(N) == 0)) or (np.all(np.diag(N) == 0)):
  #if (N[0, :].all() == 0) or (N[1, :].all() == 0) or  (N[2, :].all() == 0) or  (N[:, 0].all() == 0) or (N[:, 1].all() == 0) or (N[:, 2].all() == 0) or (np.diag(N).all() == 0) or (np.diag(np.transpose(N)).all() == 0):
    print('Yes')
    FLAGS = True
    break
  else:
    FLAGS = False
    continue
      
if FLAGS == False:     
  print('No')

Submission status: Wrong Answer

Solution code:
data=[]
for i in range(3):
    a=list(map(int,input().split()))
    data.append(a)
n=int(input())
cnt=[0]*8
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if b==data[j][k]:
                cnt[j]+=1
                cnt[k+3]+=1
                if j==k:
                    cnt[6]+=1
                if j+k==2:
                    cnt[7]+=1
if sum(cnt)!=0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

n = int(input())
for i in range(n):
	In = int(input())
    
	a1 = ['' if a1[j] == In else a1[j] for j in range(3)]
	a2 = ['' if a2[j] == In else a2[j] for j in range(3)]
	a3 = ['' if a3[j] == In else a3[j] for j in range(3)]
# tate
for i in range(2):
	if a1[i] == '' and a2[i] == '' and a3[i] == '':
		result = 'Yes'
		break
# yoko
if a1.count('') == 3:
		result = 'Yes'
if a2.count('') == 3:
		result = 'Yes'
if a3.count('') == 3:
		result = 'Yes'

# naname
if a1[0] == '' and a2[1] == '' and a3[2] == '':
		result = 'Yes'
    
if a1[2] == '' and a2[1] == '' and a3[1] == '':
		result = 'Yes'
print(result)

Submission status: Wrong Answer

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

cnt = 0
for ni in nn:
  if ni in a:
    cnt += 1
    a[a.index(ni)] = 0

judge = "No"
for i in range(3):
  if sum(a[i::3])==0 or sum(a[i*3:i*3+3])==0:
    judge = "Yes"
    
if sum(a[::4])==0 or sum(a[::-1][::4])==0:
  judge = "Yes"
  
print(judge)

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()))
A = np.array([A1, A2, A3])

N = int(input())
for i in range(N):
    B = int(input())
    A[A==B] = 0
    
result = 'No'
for i in range(3):
    if A[i].sum()==0:
        result = 'Yes'
        break
    elif A[:, i].sum()==0:
        result = 'Yes'
    else:
        pass
if np.diag(A).sum()==0:
    result = 'Yes'
elif A[0, 2]+A[1, 1]+A[2, 0]:
    result = 'Yes'

print(result)

Submission status: Wrong Answer

Solution code:
a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
a3 = [int(i) for i in input().split()]
a = [a1, a2, a3]
b = [[0] * 3] * 3
n = int(input())
for i in range(n):
    x = int(input())
    for i1 in range(3):
        for i2 in range(3):
            if a[i1][i2] == 1:
                continue

            if x == a[i1][i2]:
                b[i1][i2] = 1
                break


for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += b[i][j]
    if cnt == 3:
        print("Yes")
        exit()

if b[0][0] == b[0][1] == b[0][2] == 1 or b[2][0] == b[2][1] == b[2][0] == 1:
    print("Yes")
    exit()


print("No")

Submission status: Wrong Answer

Solution code:
A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[input() for i in range(N)]
if A11 in b and A12 in b and A13 in b:
    print('Yes')
elif A21 in b and A22 in b and A23 in b:
    print('Yes')
elif A31 in b and A32 in b and A33 in b:
    print('Yes')
elif A11 in b and A21 in b and A31 in b:
    print('Yes')
elif A12 in b and A22 in b and A32 in b:
    print('Yes')
elif A13 in b and A23 in b and A33 in b:
    print('Yes')
elif A11 in b and A22 in b and A33 in b:
    print('Yes')
elif A13 in b and A22 in b and A31 in b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for l in range(n)]
a = a[0] + a[1] + a[2]
A = [False]*9
for h in range(len(a)):
  A[h] = a[h] in b
flag = 'No'
for k in range(3):
  if A[k] ==  A[k+1] ==  A[k+2] == True:
    flag = 'Yes'
  if A[k] == A[k+3] ==  A[k+6] == True:
    flag = 'Yes'
  if A[0] ==  A[4] == A[8] == True:
    flag = 'Yes'
  if A[2] ==  A[4] ==  A[6] == True:
    flag = 'Yes'
print(flag)

Submission status: Wrong Answer

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

n = int(input())
for i in range(n):
	In = int(input())
    
	a1 = ['' if a1[j] == In else a1[j] for j in range(3)]
	a2 = ['' if a2[j] == In else a2[j] for j in range(3)]
	a3 = ['' if a3[j] == In else a3[j] for j in range(3)]

print(a1)
print(a2)
print(a3)
# tate
for i in range(2):
	if a1[i] == '' and a2[i] == '' and a3[i] == '':
		result = 'Yes'
		break
# yoko
if a1.count('') == 3:
		result = 'Yes'
if a2.count('') == 3:
		result = 'Yes'
if a3.count('') == 3:
		result = 'Yes'

# naname
if a1[0] == '' and a2[1] == '' and a3[2] == '':
		result = 'Yes'
    
if a1[2] == '' and a2[1] == '' and a3[1] == '':
		result = 'Yes'
print(result)

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()))
	
yoko = A
tate = [[], [], []]
for row in A:
	for i in range(3):
		tate[i].append(row[i])
naname = [[A[0][0], A[1][1], A[2][2]]]

all = yoko + tate + naname

y = 0
chk = 0
for kumi in all:
	for k in kumi:
		if k in b:
			chk += 1
		else:
			continue
	if chk == 3:
		print("Yes")
		y = 1
		break
	else:
		chk = 0
		
if y == 0:
	print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

bingo_list = [[],[], []]
bingo_list[0] = list(map(int, input().split()))
bingo_list[1] = list(map(int, input().split()))
bingo_list[2] = list(map(int, input().split()))
n = int(input())
b_list = [int(input()) for i in range(n)]

selected_num_list = []

# 選ばれた数字とビンゴカードが一致するか調べる
for b in b_list:
    for i in range(3):
        for j in range(3):
            if b == bingo_list[i][j]:
                selected_num_list.append((i, j))

# ビンゴかどうか調べる
bingo_flag = False
for i in range(3):
    line_flag = False
    for j in range(3):
        if (i, j) in selected_num_list:
            line_flag = True
        else:
            line_flag = False
            break
    if line_flag == True:
        bingo_flag = True
        break

# 縦
for i in range(3):
    row_flag = False
    for j in range(3):
        if (j, i) in selected_num_list:
            row_flag = True
        else:
            row_flag = False
            break
    if row_flag == True:
        bingo_flag = True
        break

# 斜め
cross_flag = False
for i in range(3):
    for j in range(3):
        if i == j:
            if (i, j) in selected_num_list:
                cross_flag = True
            else:
                cross_flag = False

if cross_flag == True:
    bingo_flag = True

# 逆斜め
cross_flag = False
if (0, 2) in selected_num_list:
    if (1, 1) in selected_num_list:
        if (2, 0) in selected_num_list:
            bingo_flag = True


# 表示
if bingo_flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def resolve():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for i in range(n):
        b = int(input())
        for j in range(len(a)):
            if a[j] == b:
                a[j] = -1
    x1 = a[0:2].count(-1)
    x2 = a[3:5].count(-1)
    x3 = a[6:9].count(-1)
    y1 = a[0:6:3].count(-1)
    y2 = a[1:7:3].count(-1)
    y3 = a[2:9:3].count(-1)
    nn = a[0:9:4].count(-1)

    if x1 == 3 or x2 == 3 or x3 == 3 or y1 == 3 or y2 == 3 or y3 == 3 or nn == 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
As = [list(map(int, input().split())) for x in range(3)]
N = int(input())
bs = [int(input()) for x in range(N)]
def createBingo():
  result = [[0,0,0] for x in range(3)]
  i = 0
  while True:
    i2 = 0
    while True:
      if bs[i2] in As[i]:
        result[i][As[i].index(bs[i2])] += 1
      i2 += 1
      if i2 == len(bs)-1:
        break
    i += 1
    if i == len(As):
      break
  return result

def solvd(bingo):
  r = 0
  for x in range(2):
    tmp = set([bingo[x][0], bingo[x][1], bingo[x][2]])
    if check(tmp):
      print("Yes")
      return
    if x == 0:
      tmp = set([bingo[0][0], bingo[1][1], bingo[2][2]])
      if check(tmp):
        print("Yes")
        return
    elif x == 2:
      tmp = set(bingo[0][2] == bingo[1][1] == bingo[2][0])
      if check(tmp):
        print("Yes")
        return
    bingoSet = set(bingo[x])
    if check(bingoSet):
      r += 1

  if r == 3:
    print("Yes")
  else:
    print("No")

def check(s):
  return len(s) == 1 and list(s)[0] != 0

def main():
  Cs = createBingo()
  solvd(Cs)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
bingo = {}
for i in range(3):
    a,b,c = map(int, input().strip().split())
    bingo[a] = [i, 0]
    bingo[b] = [i, 1]
    bingo[c] = [i, 2]

answer = [[[0, 0], [0, 1], [0, 2]],
          [[1, 0], [1, 1], [1,2]],
          [[2,0], [2,1],[2,2]],
          [[0,0],[1,0],[2,0]],
          [[1,0],[1,1],[1,2]],
          [[2,0],[2,1],[2,2]],
          [[0,0],[1,1],[2,2]],
          [[2,0],[1,1],[0,2]]]
n = int(input())
ans = []
for i in range(n):
  tmp = int(input())
  if tmp in bingo.keys():
    ans += [bingo[tmp]]

for a in answer:
  for ai in a:
    f_ans = False
    if ai in ans:
      f_ans = True
    else:
      f_ans = False
  if f_ans:
    break
    
if f_ans:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
Z=list(map(int,input().split()))
N=int(input())
b=[input() for i in range(N)]
if b.count(X[0])>0 and b.count(X[1])>0 and b.count(X[2])>0:
    print("Yes")
    exit()
if b.count(Y[0])>0 and b.count(Y[1])>0 and b.count(Y[2])>0:
    print("Yes")
    exit()
if b.count(Z[0])>0 and b.count(Z[1])>0 and b.count(Z[2])>0:
    print("Yes")
    exit()
if b.count(X[0])>0 and b.count(Y[0])>0 and b.count(Z[0])>0:
    print("Yes")
    exit()
if b.count(X[1])>0 and b.count(Y[1])>0 and b.count(Z[1])>0:
    print("Yes")
    exit()
if b.count(X[2])>0 and b.count(Y[2])>0 and b.count(Z[2])>0:
    print("Yes")
    exit()
if b.count(X[0])>0 and b.count(Y[1])>0 and b.count(Z[2])>0:
    print("Yes")
    exit()
if b.count(X[2])>0 and b.count(Y[1])>0 and b.count(Z[0])>0:
    print("Yes")
    exit()
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())

a = a + b + c

list = []

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

b = [0,0,0,0,0,0,0,0,0]

for i in range(len(a)):
    for j in range(len(list)):
        if a[i] == list[j]:
            b[i] = 1

sum = 0
for i in range(len(b)):
    sum = sum + b[i]

if sum == 0:
    print("No")
elif b[2]+b[4]+b[6] ==3:
    print("Yes")
elif b[0]+b[1]+b[2] ==3:
    print("Yes")
elif b[3]+b[4]+b[5] ==3:
    print("Yes")
elif b[6]+b[7]+b[8] ==3:
    print("Yes")
elif b[0]+b[4]+b[8] ==3:
    print("Yes")
elif b[2]+b[5]+b[8] ==6:
    print("Yes")
elif b[1]+b[4]+b[7] ==3:
    print("Yes")
elif b[0]+b[3]+b[6] ==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst3 = list(map(int, input().split()))
bng1=[0, 0, 0]
bng2=[0, 0, 0]
bng3=[0, 0, 0]
n = int(input())
for i in range(n):
    b = int(input())
    for i in range(3):
        if b == lst1[i]:
            bng1[i] = 1
        if b == lst2[i]:
            bng2[i] = 1
        if b == lst3[i]:
            bng3[i] = 1
    if '0' in bng1 == False or '0' in bng2 == False or '0' in bng3 == False:
        print('Yes')
        exit()
    elif bng1[0] * bng2[1] * bng3[2] != 0 or  bng1[2] * bng2[1] * bng3[0] != 0:
        print('Yes')
        exit()
    elif bng1[0] * bng2[0] * bng3[0] != 0 or  bng1[1] * bng2[1] * bng3[1] != 0 or  bng1[2] * bng2[2] * bng3[2] != 0:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
import math
def common_member(a, b): 
    a_set = set(a) 
    b_set = set(b) 
    if (a_set & b_set): 
        return len(a_set & b_set)
    else: 
        return 0

L = list(map(int,input().split()))
L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))
LL = L + L1 + L2
N = int(input())
NN = math.ceil(N/2)
M = []
for i in range(N):
    ML = input()
    M.append(int(ML))

res = common_member(M,LL)
if(res == 0):
    print("No")
elif (res >= (NN/2)):
    print("Yes")

Submission status: Wrong Answer

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

def is_bingo(ls, b):
    bingo = True
    for val in row:
        if val not in b:
            bingo = False
    return bingo

result = 'No'
for i in range(3):
    row = a[i][:]
    column = a[:][i]
    if is_bingo(row, b) or is_bingo(column, b):
        result = 'Yes'

diag1 = [a[0][0], a[1][1], a[2][2]]
diag2 = [a[2][0], a[1][1], a[0][2]]

if is_bingo(diag1, b) or is_bingo(diag2, b):
    result = 'Yes'

print(result)

Submission status: Wrong Answer

Solution code:
import numpy as np
A_1 = [int(i) for i in input().split()]
A_2 = [int(i) for i in input().split()]
A_3 = [int(i) for i in input().split()]
A = np.array([A_1, A_2, A_3])
N = int(input())
b = [int(input()) for i in range(N)]
for i in b:
   A = np.where(A==i,0,A) 

if ((A[0][0]==A[1][1]) and (A[1][1] == A[2][2])):
    print('Yes')
elif ((A[2][0]==A[1][1]) and (A[1][1] == A[0][2])):
    print('Yes')
elif A[0,:].all()==0 or A[:,0].all()==0:
    print('Yes')
elif A[1,:].all()==0 or A[:,1].all()==0:
    print('Yes')
elif A[2,:].all()==0 or A[:,2].all()==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)]


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

if a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
bingo = [[],[],[]]
 
for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
    sys.exit()
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 b in B:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = 0
f = False
for i in range(3):
  s = 0
  for j in range(3):
    s += A[i][j]
  if s == 0:
    f = True
for i in range(3):
  s = 0
  for j in range(3):
    s += A[j][i]
  if s == 0:
    f = True
s = 0
for i in range(3):
  s += A[i][i]
  if s == 0:
    f = True
s = 0
for i in range(3):
  s += A[i][2-i]
  if s == 0:
    f = True
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
import numpy as np

a1,a2,a3 = map(int,input().split())
a4,a5,a6 = map(int,input().split())
a7,a8,a9 = map(int,input().split())

a = np.array([[a1, a2, a3], [a4, a5, a6], [a7, a8, a9]])

n = int(input())
for i in range(n):
  b = int(input())
  a = np.where(a == b, 0, a)

print(a)

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

Submission status: Wrong Answer

Solution code:
bingo = [ input().split() for j in range(3)]
N = int(input())
b = []
for n in range(N):
	b.append(input())
count = 0
total = 0
p = 'No'
for x in range(N):
	for i in range(3):
		for j in range(3):
			count = count + 1
			if bingo[i][j] == b[x]:
				total = total + count
	count = 0
	if total == 6 or total == 12 or total == 15 or total == 18 or total == 24:
		p = 'Yes'
		break
print(p)

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())
P = [list(map(int,input().split())) for i in range(N)]

Hit = True

for i in P:
    if i in A:
        A[A.index(i)] = Hit
    elif i in B:
        B[B.index(i)] = Hit
    elif i in C:
        C[C.index(i)] = Hit

if all(A[:]):
    print("Yes")
elif all(B[:]):
    print("Yes")
elif all(C[:]):
    print("Yes")
elif all((A[0],B[0],C[0])):
         print("Yes")
elif all((A[1],B[1],C[1])):
         print("Yes")
elif all((A[2],B[2],C[2])):
         print("Yes")                                               
elif all((A[0],B[1],C[2])):
         print("Yes")
elif all((A[2],B[1],C[0])):
         print("Yes")
else:
    print("No")