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_1 = list(map(int,input().split(" ")))
a_2 = list(map(int,input().split(" ")))
a_3 = list(map(int,input().split(" ")))
n = int(input())
open_number =[]
for i in range(3):
  open_number.append([0,0,0])
for i in range(n):
  number = int(input())
  for j in range(3):
    if number == a_1[j]:
      open_number[0][j] = 1
    if number == a_2[j]:
      open_number[1][j] = 1
    if number == a_3[j]:
      open_number[2][j] = 1
bingo = False
line_1 = 0
line_2 = 0
line_3 = 0
cross_1 = 0
cross_2 = 0
for i in range(3):
  if not 0 in open_number[i]:
    bingo = True
  if open_number[0][i] == 1:
    line_1 += 1
  if open_number[1][i] == 1:
    line_2 += 1
  if open_number[2][i] == 1:
    line_3 += 1
  if open_number[i][i] == 1:
    cross_1 += 1
  if open_number[2-i][i] == 1:
    cross_2 += 1
  if line_1 == 3:
    bingo = True
  if line_2 == 3:
    bingo = True
  if line_3 == 3:
    bingo = True
  if cross_1 == 3:
    bingo = True
  if cross_2 == 3:
    bingo = True
if bingo:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a_1 = list(map(int,input().split(" ")))
a_2 = list(map(int,input().split(" ")))
a_3 = list(map(int,input().split(" ")))
n = int(input())
open_number =[]
for i in range(3):
  open_number.append([0,0,0])
for i in range(n):
  number = int(input())
  for j in range(3):
    if number == a_1[j]:
      open_number[0][j] = 1
    if number == a_2[j]:
      open_number[1][j] = 1
    if number == a_3[j]:
      open_number[2][j] = 1
bingo = False
cross_1 = 0
cross_2 = 0
for i in range(3):
  if not 0 in open_number[i]:
    bingo = True
  if open_number[i][i] == 1:
    cross_1 += 1
  if open_number[2-i][i] == 1:
    cross_2 += 1
  if cross_1 == 3:
    bingo = True
  if cross_2 == 3:
    bingo = True
if bingo:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

for i in range(3):
	if sum(a2[i]) == 3:
		print('Yes')
		sys.exit()
tate = 0
for i in range(3):
	for j in range(3):
		if a2[i][j] == 1:
			tate += 1
	if tate == 3:
		print('Yes')
		sys.exit()
	tate = 0
naname = 0
for i in range(3):
	if a2[i][i] == 1:
		naname += 1
if naname == 3:
	print('Yes')
	sys.exit()
naname = 0
for i in range(3):
	if a2[i][-i-1] == 1:
		naname += 1
if naname == 3:
	print('Yes')
	sys.exit()
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='No'

for i in range(3):
    for j in range(3):
        print(A[i][j])
        if A[i][j] in B:
            A[i][j]=-1

for i in range(3):
    if sum(A[i])==-3:
        ans='Yes'
    if A[0][i]+A[1][i]+A[2][i]==-3:
        ans='Yes'

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
input1  = input().split()
input2  = input().split()
input3  = input().split()
N = int(input())

A = [input1, input2, input3]


for i in range(N):
  n = input()
  A[0] = ['0' if j == n else j for j in A[0]]
  A[1] = ['0' if j == n else j for j in A[1]]
  A[2] = ['0' if j == n else j for j in A[2]]



ans = 'No'
if A[1][1] == A[2][2] == A[0][0] == "0":
  ans = "Yes"
  
for i in range(3):
  if A[i] == ['0','0','0']:
    ans = "Yes"
  if A[0][i] == A[1][i] == A[2][i] == "0":
    ans ='Yes'
  
print(ans)

Submission status: Wrong Answer

Solution code:
mat = []
for _ in range(3):
    mat.append(list(map(int, input().split())))
N = int(input())
nums = set()
for _ in range(N):
    nums.add(int(input()))
rows = [3] * 3
cols = [3] * 3
diags = [3] * 2
for i in range(3):
    for j in range(3):
        if mat[i][j] in nums:
            rows[i] -= 1
            cols[j] -= 1
            if i == j:
                diags[0] -= 1
            elif i == 2 - j:
                diags[1] -= 1
print(["No", "Yes"][0 in (rows + cols + diags)])

Submission status: Wrong Answer

Solution code:
S = [list(map(int, input().split())) for _ in range(3)]
s = []
for i in range(3):
    for j in range(3):
        s.append(S[i][j])
n = int(input())
a = [int(input()) for i in range(n)]
print(s[0]in a and s[1] in a and s[2] in a)
if (s[0]in a and s[1] in a and s[2] in a)or(s[3]in a and s[4] in a and s[5] in a)or(s[6]in a and s[7] in a and s[8] in a)or(s[0]in a and s[3] in a and s[6] in a)or(s[4]in a and s[1] in a and s[7] in a)or(s[2]in a and s[5] in a and s[8] in a)or(s[0]in a and s[4] in a and s[8] in a)or(s[2]in a and s[4] in a and s[6] in a):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math
line1 = list(map(int, input().split()))
line2 = list(map(int, input().split()))
line3 = list(map(int, input().split()))
lines = [line1, line2, line3]
N = int(input())
List = [int(input()) for i in range(4, N + 4)]

for num in List:
    for i in range(len(lines)):
        for j in range(len(lines)):
            if lines[i][j] == num:
                lines[i][j] = -1



if (lines[0][0] == -1 and lines[0][1] == lines[0][0] and lines[0][2] == lines[0][0]) or (lines[1][0] == -1 and lines[1][1] == lines[1][0] and lines[1][2] == lines[1][0]) or (lines[2][0] == -1 and lines[2][1] == lines[2][0] and lines[2][2] == lines[2][0]) or (lines[0][0] == -1 and lines[1][0] == lines[0][0] and lines[2][0] == lines[0][0]) or (lines[1][0] == -1 and lines[1][1] == lines[1][0] and lines[1][2] == lines[1][0]) or (lines[2][0] == -1 and lines[2][1] == lines[2][0] and lines[2][2] == lines[2][0]) or (lines[0][0] == -1 and lines[1][1] == lines[0][0] and lines[2][2] == lines[0][0]) or (lines[0][2] == -1 and lines[1][1] == lines[0][2] and lines[2][0] == lines[0][2]):
  print("Yes")
else: print("No")

Submission status: Wrong Answer

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

n = int(input())

v = []
for j in range(n):
    v.append(int(input()))

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

bingo = False
for i in range(3):
    if a[i][0] == -1 and a[i][0] == -1 and a[i][0] == -1:
        bingo = True
    if a[0][i] == -1 and a[0][i] == -1 and a[0][i] == -1:
        bingo = True

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    bingo = True
elif a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    bingo = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

n = int(input())

v = []
for j in range(n):
    v.append(int(input()))

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

bingo = False
for i in range(3):
    if a[i][0] == -1 and a[i][0] == -1 and a[i][0] == -1:
        bingo = True
    if a[0][i] == -1 and a[0][i] == -1 and a[0][i] == -1:
        bingo = True

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    bingo = True
elif a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    bingo = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

n = int(input())

v = []
for j in range(n):
    v.append(int(input()))

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

bingo = False
for i in range(3):
    if a[i,:].all == -1:
        bingo = True
    if a[:,i].all == -1:
        bingo = True

if a[0,0] == -1 and a[1,1] == -1 and a[2,2] == -1:
    bingo = True
elif a[0,2] == -1 and a[1,1] == -1 and a[2,0] == -1:
    bingo = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

n = int(input())

for j in range(n):
    val2 = int(input())
    if val2 in a:
        a = np.where(a==val2, -1, a)

bingo = False
for i in range(3):
    if a[i,:].all == -1:
        bingo = True
        break
    if a[:,i].all == -1:
        bingo = True
        break
if a[0,0] == -1 and a[1,1] == -1 and a[2,2] == -1:
    bingo = True
if a[0,2] == -1 and a[1,1] == -1 and a[2,0] == -1:
    bingo = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

n = int(input())

for j in range(n):
    val2 = int(input())
    if val2 in a:
        a = np.where(a==val2, -1, a)

bingo = False
if np.sum(a==-1) >=3:
    for i in range(3):
        if a[i,:].all == -1:
            bingo = True
            break
        if not bingo:
            if a[:,i].all == -1:
                bingo = True
                break
    if not bingo:
        if a[0,0] == -1 and a[1,1] == -1 and a[2,2] == -1:
            bingo = True
        elif a[0,2] == -1 and a[1,1] == -1 and a[2,0] == -1:
            bingo = True


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

Submission status: Wrong Answer

Solution code:
s1=list(map(int, input().split()))
s2=list(map(int, input().split()))
s3=list(map(int, input().split()))
n = int(input())
A=set()
for i in range(n):
	s=int(input())
	A.add(s)
c=[0]*9
for i in range(3):
	if s1[i] in A:
		c[i]+=1

for i in range(3):
	if s2[i] in A:
		c[i+3]+=1

for i in range(3):
	if s3[i] in A:
		c[i+6]+=1
p=0
#naname
if c[0]+c[4]+c[8]==3:
	print('Yes')
	p+=1
if c[2]+c[4]+c[6]==3:
	print('Yes')
	p+=1

#yoko
if p==0 and c[0]+c[1]+c[2]==3:
	print('Yes')
	p+=1
if p==0 and c[3]+c[4]+c[5]==3:
	print('Yes')
	p+=1
if p==0 and c[6]+c[7]+c[8]==3:
	print('Yes')
	p+=1
#tate
for i in range(3):
	if p==0 and c[i]+c[3+i]+c[6+i]==3:
		print('Yes')
		p+=1

if p==0:
	print('No')

Submission status: Wrong Answer

Solution code:
s1=list(map(int, input().split()))
s2=list(map(int, input().split()))
s3=list(map(int, input().split()))
n = int(input())
A=set()
for i in range(n):
	s=int(input())
	A.add(s)
c=[0]*9
for i in range(3):
	if s1[i] in A:
		c[i]+=1

for i in range(3):
	if s2[i] in A:
		c[i+3]+=1

for i in range(3):
	if s3[i] in A:
		c[i+6]+=1
p=0
#naname
if c[0]+c[4]+c[8]==3:
	print('Yes')
	p+=1
if c[2]+c[4]+c[7]==3:
	print('Yes')
	p+=1

#yoko
if p==0 and c[0]+c[1]+c[2]==3:
	print('Yes')
	p+=1
if p==0 and c[3]+c[4]+c[5]==3:
	print('Yes')
	p+=1
if p==0 and c[6]+c[7]+c[8]==3:
	print('Yes')
	p+=1
#tate
for i in range(3):
	if p==0 and c[i]+c[3+i]+c[6+i]==3:
		print('Yes')
		p+=1

if p==0:
	print('No')

Submission status: Wrong Answer

Solution code:
s1=list(map(int, input().split()))
s2=list(map(int, input().split()))
s3=list(map(int, input().split()))
n = int(input())
A=set()
for i in range(n):
	s=int(input())
	A.add(s)
c=[0]*9
for i in range(3):
	if s1[i] in A:
		c[i]+=1

for i in range(3):
	if s2[i] in A:
		c[i+3]+=1

for i in range(3):
	if s3[i] in A:
		c[i+6]+=1
p=0
#naname
if c[0]+c[4]+c[8]==3:
	print('Yes')
	p+=1
if c[3]+c[4]+c[7]==3:
	print('Yes')
	p+=1

#yoko
if p==0 and c[0]+c[1]+c[2]==3:
	print('Yes')
	p+=1
if p==0 and c[3]+c[4]+c[5]==3:
	print('Yes')
	p+=1
if p==0 and c[6]+c[7]+c[8]==3:
	print('Yes')
	p+=1
#tate
for i in range(3):
	if p==0 and c[i]+c[3+i]+c[6+i]==3:
		print('Yes')
		p+=1

if p==0:
	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)]

for i in b:
  for j in range(3):
    if i in A[j]:
      A[j][A[j].index(i)] = 0
else:
  for i in range(3):
    if (A[0][j] + A[1][j] + A[2][j] == 0) or (A[j][0] + A[j][1] + A[j][2] == 0):
      print('Yes')
      break
  else:
    if (A[0][0] + A[1][1] + A[2][2] == 0) or (A[0][2] + A[1][1] + A[2][0] == 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 = [int(input()) for i in range(N)]

for i in b:
  for j in range(3):
    if i in A[j]:
      A[j][A[j].index(i)] = 0
else:
  for i in range(3):
    if (A[0][j] + A[1][j] + A[2][j] == 0) or (A[j][0] + A[j][1] + A[j][2] == 0):
      print('Yes')
  else:
    if (A[0][0] + A[1][1] + A[2][2] == 0) or (A[0][2] + A[1][1] + A[2][0] == 0):
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
import sys



bingo = [[int(c) for c in input().split()] for _ in range(3)]
n = int(input())
a = [int(input()) for _ in range(n)]

ans = [[0,0,0],[0,0,0],[0,0,0]]
num =0

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[i] == bingo[j][k]:
                ans[j][k] = 1
                num += 1
if num < 3:
    print("No")
    exit()

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


for i in range(3):

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

Submission status: Wrong Answer

Solution code:
import sys



bingo = [[int(c) for c in input().split()] for _ in range(3)]
n = int(input())
a = [int(input()) for _ in range(n)]

ans = [[0,0,0],[0,0,0],[0,0,0]]
num =0

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[i] == bingo[j][k]:
                ans[j][k] = 1
                num += 1
if num < 3:
    print("No")
    exit()



for i in range(3):

    if ans[i][0] == 1 and ans[i][1] == 1 and ans[i][2] == 1:
        print("Yes")
        exit()
    elif ans[0][i] == 1 and ans[1][i] == 1 and ans[2][i] == 1:
        print("Yes")
        exit()
    elif ans[1][1] == 1:
        if (ans[0][0] == 1 and ans[2][2]==1) or ( ans[0][2] == 1 and ans[2][0] == 1):
            print("Yes")
            exit()
        else :
            print("No")
            exit()
    else:
            print("No")
            exit()

Submission status: Wrong Answer

Solution code:
import sys



bingo = [[int(c) for c in input().split()] for _ in range(3)]
n = int(input())
a = [int(input()) for _ in range(n)]

ans = [[0,0,0],[0,0,0],[0,0,0]]
num =0

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[i] == bingo[j][k]:
                ans[j][k] = 1
                num += 1
if num < 3:
    print("No")
    exit()



for i in range(3):

    if ans[i][0] == 1 and ans[i][1] == 1 and ans[i][2] == 1:
        print("Yes")
        exit()
    elif ans[0][i] == 1 and ans[1][i] == 1 and ans[2][i] == 1:
        print("Yes")
        exit()
    elif ans[1][1] == 1:
        if (ans[0][0] == 1 and ans[2][2]) or ( ans[0][2] == 1 and ans[2][0] == 1):
            print("Yes")
            exit()
        else :
            print("No")
    else:
            print("No")

Submission status: Wrong Answer

Solution code:
a = [0]*3
for i in range(3):
    a[i] = list(map(int,input().split()))
n = int(input())
b = [0]*n
sw = [[0]*3]*3
ans = 0
for i in range(n):
    b[i] = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                sw[j][k] = 1
            else:
                pass
for i in range(3):
    if sw[i][0] == 1 and sw[i][1] == 1 and sw[i][2] == 1:
        ans = 1
    elif sw[0][i] == 1 and sw[1][i] == 1 and sw[2][i] == 1:
        ans = 1
if sw[0][0] == 1 and sw[1][1] == 1 and sw[2][2] == 1:
    ans = 1
elif sw[0][2] == 1 and sw[1][1] == 1 and sw[2][0] == 1:
    ans = 1

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    A1 = LI()
    A2 = LI()
    A3 = LI()
    N = II()
    b = [int(input()) for i in range(N)]
    ans = 0
    #print(b)

    if b.count(A2[1])!=0:
        if (b.count(A1[0])!=0 and b.count(A3[2])!=0) or (b.count(A3[0])!=0 and b.count(A1[2])!=0) :
            ans += 1
    if b.count(A1[0])!=0:
        if (b.count(A2[0])!=0 and b.count(A3[0])!=0) or (b.count(A1[1])!=0 and b.count(A1[2])!=0) :
            ans += 1
    if b.count(A3[2])!=0:
        if (b.count(A1[2])!=0 and b.count(A2[2])!=0) or (b.count(A3[0])!=0 and b.count(A3[1])!=0) :
            ans += 1
    if ans != 0:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
	main()

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())
listb = [input() for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[0] == A2[1] == A3[2] or A1[2] == A2[1] == A3[0]:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

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

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

ans = "No"
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0:
    print("Yes")
print(ans)

Submission status: Wrong Answer

Solution code:
import os

card = []
for i in range(3):
    list = [int(i) for i in input().split()]
    card = card + list
n = int(input())
if n>=7:
    print('Yes')
    exit()
bingo = []
for i in range(n):
    bingo.append(i)

for j in range(9):
    if card[j] is bingo:
        card[j] = -1

if card[0]+card[1]+card[2]==-3 or card[3]+card[4]+card[5]==-3 or card[6]+card[7]+card[8]==-3 or card[0]+card[3]+card[6]==-3 or card[1]+card[4]+card[7]==-3 or card[2]+card[5]+card[8]==-3 or card[0]+card[4]+card[8]==-3 or card[3]+card[4]+card[6]==-3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a = [input().split() for _ in range(3)]
n = int(input())
for _ in range(n):
    b = input()
    cnt = -1
    for i in a:
        cnt+=1
        if b in i:
            pos = i.index(b)
            a[cnt][pos] = "0"

bingo = ["0","0","0"]
for i in a:
    if a == bingo:
        print("Yes")
        exit()
if a[0][0] == a[1][1] == a[2][2] == "0" or a[0][2] == a[1][1] == a[2][0] == "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()))
n = int(input())
b = [int(input()) for i in range(n)]
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
tmp = []
for i in range(3):
    for j in range(len(b)):
        if b[j] == A1[i]:
            A1[i] = 0
        elif b[j] == A2[i]:
            A2[i] = 0
        
        elif b[j] == A3[i]:
            A3[i] = 0

if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print("Yes")

elif A1[0]+A2[0]+A3[0] == 0 or A1[1]+A2[1]+A3[1] == 0 or A1[2]+A2[2]+A3[2] == 0:
    print("Yes")

elif A1[0]+A2[1]+A3[2] == 0 or A1[2]+A2[1]+A3[0]:
    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()))
N = int(input())
K = [[0,0,0]]*3
for i in range(N):
    s = int(input())
    flag = 0
    for j in range(3):
        if s == A[j]:
            K[0][j] += 1
            flag += 1
            break
    if flag == 1:
        continue
    else:
        for j in range(3):
            if s == B[j]:
                K[1][j] += 1
                flag += 1
                break
        if flag == 1:
            continue
        else:
            for j in range(3):
                if s == C[j]:
                    K[2][j] += 1
                    flag += 1
                    break
flag_2 = 0
if K[0][0] > 0 and K[0][1] > 0 and K[0][2] > 0:
    flag_2 += 1
if K[1][0] > 0 and K[1][1] > 0 and K[1][2] > 0:
    flag_2 += 1
if K[2][0] > 0 and K[2][1] > 0 and K[2][2] > 0:
    flag_2 += 1
if K[0][0] > 0 and K[1][0] > 0 and K[2][0] > 0:
    flag_2 += 1
if K[0][1] > 0 and K[1][1] > 0 and K[2][1] > 0:
    flag_2 += 1
if K[0][2] > 0 and K[1][2] > 0 and K[2][2] > 0:
    flag_2 += 1
if K[0][0] > 0 and K[1][1] > 0 and K[2][2] > 0:
    flag_2 += 1
if K[2][0] > 0 and K[1][1] > 0 and K[0][2] > 0:
    flag_2 += 1
if flag_2 >0:
    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()))
    A.append(a)

N = int(input())
B1 = []
for n in range(N):
    b = int(input())
    B1.append(b)
B2 = list(set(B1))

for y in range(3):
    for z in range(3):
        for x in B2:
            if x == A[y][z]:
                A[y][z] = 0

for i in range(3):
    if A[i] == 0:
        print("Yes")
        sys.exit(0)
for i in range(3):
    if A[0][i] + A[1][i] + A[2][i] == 0:
        print("Yes")
        sys.exit(0)
if A[0][0] + A[1][1] + A[2][2] == 0:
    print("Yes")
    sys.exit(0)
if A[2][0] + A[1][1] + A[0][2] == 0:
    print("Yes")
    sys.exit(0)
    
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)]
##一致個所の確認
for i in range(3):
  for j in range(N):
    if A1[i] == b[j]:
      A1[i] = 0
for i in range(3):
  for j in range(N):
    if A2[i] == b[j]:
      A2[i] = 0
for i in range(3):
  for j in range(N):
    if A3[i] == b[j]:
      A3[i] = 0
if N < 3:
  print('No')
else:
  ##横ラインビンゴ確認
  if (A1[i] == 0 for i in range(3)) or (A2[i] == 0 for i in range(3)) or (A3[i] == 0 for i in range(3)):
    print('Yes')
  #縦ラインビンゴ確認
  elif (A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or (A1[1] == 0 and A2[1] == 0 and A3[1] == 0) or (A1[2] == 0 and A2[2] == 0 and A3[2] == 0):
      print('Yes')
  #斜めビンゴ確認
  elif (A1[0] == 0 and A2[1] == 0 and A3[2] == 0) or (A1[2] == 0 and A2[1] == 0 and A3[0] == 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()))
N = int(input())
b = [int(input()) for _ in range(N)]
##一致個所の確認
for i in range(3):
  for j in range(N):
    if A1[i] == b[j]:
      A1[i] = 0
for i in range(3):
  for j in range(N):
    if A2[i] == b[j]:
      A2[i] = 0
for i in range(3):
  for j in range(N):
    if A3[i] == b[j]:
      A3[i] = 0
##横ラインビンゴ確認
if (A1[i] == 0 for i in range(3)) or (A2[i] == 0 for i in range(3)) or (A3[i] == 0 for i in range(3)):
  print('Yes')
#縦ラインビンゴ確認
elif (A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or (A1[1] == 0 and A2[1] == 0 and A3[1] == 0) or (A1[2] == 0 and A2[2] == 0 and A3[2] == 0):
  print('Yes')
#斜めビンゴ確認
elif (A1[0] == 0 and A2[1] == 0 and A3[2] == 0) or (A1[2] == 0 and A2[1] == 0 and A3[0] == 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()))
N = int(input())
b = [int(input()) for _ in range(N)]
##一致個所の確認
for i in range(3):
  for j in range(N):
    if A1[i] == b[j]:
      A1[i] = 0
for i in range(3):
  for j in range(N):
    if A2[i] == b[j]:
      A2[i] = 0
for i in range(3):
  for j in range(N):
    if A3[i] == b[j]:
      A3[i] = 0
##横ラインビンゴ確認
if (B1[i] == 0 for i in range(3)) or (B2[i] == 0 for i in range(3)) or (B3[i] == 0 for i in range(3)):
  print('Yes')
#縦ラインビンゴ確認
elif (A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or (A1[1] == 0 and A2[1] == 0 and A3[1] == 0) or (A1[2] == 0 and A2[2] == 0 and A3[2] == 0):
  print('Yes')
#斜めビンゴ確認
elif (A1[0] == 0 and A2[1] == 0 and A3[2] == 0) or (A1[2] == 0 and A2[1] == 0 and A3[0] == 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()))
N = int(input())
b = [int(input()) for _ in range(N)]
##一致個所の確認
for i in range(3):
  for j in range(N):
    if A1[i] == b[j]:
      A1[i] = 0
for i in range(3):
  for j in range(N):
    if A2[i] == b[j]:
      A2[i] = 0
for i in range(3):
  for j in range(N):
    if A3[i] == b[j]:
      A3[i] = 0
##横ラインビンゴ確認
B1 = list(set(A1))
B2 = list(set(A2))
B3 = list(set(A3))
if B1[0] == 0 or B2[0] == 0 or B3[0] == 0:
  print('Yes')
#縦ラインビンゴ確認
elif (A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or (A1[1] == 0 and A2[1] == 0 and A3[1] == 0) or (A1[2] == 0 and A2[2] == 0 and A3[2] == 0):
  print('Yes')
#斜めビンゴ確認
elif (A1[0] == 0 and A2[1] == 0 and A3[2] == 0) or (A1[2] == 0 and A2[1] == 0 and A3[0] == 0):
  print('Yes')
#はずれ
else:
  print('No')

Submission status: Wrong Answer

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

    for i in range(3):
        if (A[i][0] in b and A[i][1] in b and A[i][2]) or (A[0][i] in b and A[1][i] in b and A[2][i]):
            print('Yes')
            return
    if (A[0][0] in b and A[1][1] in b and A[2][2]) or (A[2][0] in b and A[1][1] in b and A[0][2]):
        print('Yes')
        return
    print('No')

solve()

Submission status: Wrong Answer

Solution code:
a= []
for i in range(3):
  a_input = input().split(" ")
  a.append(a_input)


n = int(input())

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

for i in range(3):
    #縦
    if a[0][i] =="0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
      break
    #横
    elif a[i][0] =="0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
      break
    #斜め（右上から左下）
    elif a[0][0] =="0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
      break
    #斜め（右下から左上）  
    elif a[0][2] =="0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
      break
print("No")

Submission status: Wrong Answer

Solution code:
a= []
for i in range(3):
  a_input = input().split(" ")
  a.append(a_input)


n = int(input())

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

for i in range(3):
    #縦
    if a[0][i] =="0" and a[0][i] == a[1][i] and a[0][i] == a[2][i]:
      print("Yes")
      break
    #横
    elif a[i][0] =="0" and a[i][0] == a[i][1] and a[i][0] == a[i][2]:
      print("Yes")
      break
    #斜め（右上から左下）
    elif a[0][0] =="0" and a[0][0] == a[1][1] and a[1][1] == a[2][2]:
      print("Yes")
      break
    #斜め（右下から左上）  
    elif a[0][2] =="0" and a[0][2] == a[1][1] and a[0][2] == a[2][0]:
      print("Yes")
      break
    else:
      pass
    print("No")

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        if bingo[i][j] in ls:
            bingo[i][j] = 1
        else:
            bingo[i][j] = 0

if sum(bingo[0]) == 3 or sum(bingo[1]) == 3 or sum(bingo[1]) == 3:
    print('Yes')
    exit()

if sum(bingo[i][0] for i in range(3)) == 3 or sum(bingo[i][1] for i in range(3)) == 3 or sum(bingo[i][2] for i in range(3)) == 3:
    print('Yes')
    exit()

if bingo[0][0] + bingo[1][1] + bingo[2][2] == 3 or bingo[0][2] + bingo[1][1] + bingo[2][0] == 3:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

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

N = int(input())
B1 = []
for n in range(N):
    b = int(input())
    B1.append(b)
B2 = list(set(B1))

for y in range(3):
    for z in range(3):
        for x in B2:
            if x == A[y][z]:
                A[y][z] = 0

if A[0] == 0 or A[1] == 0 or A[2] == 0:
    print("Yes")
    sys.exit(0)
elif A[0][0] == A[1][1] and A[1][1] == A[2][2] and A[0][0] == 0:
    print("Yes")
    sys.exit(0)
elif A[0][2] == A[1][1] and A[1][1] == A[2][0] and A[0][2] == 0:
    print("Yes")
    sys.exit(0)
for k in range(3):
    if A[0][k] == A[1][k] and A[1][k] == A[2][k] and A[0][k] == 0:
        print("Yes")
        sys.exit(0)
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)]
for i in range(3):
  for j in range(3):
    for k in b:
      if a[j][i] == k:
            a[j][i] = 'o'
a1 = list(set(a[0]))
a2 = list(set(a[1]))
a3 = list(set(a[2]))
a4 = list(set((a[0][0],a[1][1],a[2][2])))
a5 = list(set((a[0][2],a[1][1],a[2][0])))
a6 = list(set((a[0][0],a[1][0],a[2][0])))
a7 = list(set((a[0][1],a[1][1],a[2][1])))
a8 = list(set((a[0][2],a[1][2],a[2][2])))
p = ['o']
A = [a1,a2,a3,a4,a5,a6,a7,a8]
for i in A:
    ans = 'No'
    if i == p:
        ans = 'Yes'
        break
print(ans)
print(A)