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

field = 0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			field = field | 1 << i
ans = False
for i in range(3):
	ans = ans or field & 7 << (i * 3) or field & 73 << i
ans = ans or field & 273 or field & 84
print('Yes' if ans else 'No')

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
a = []
b = []
ans = 'No'

for i in range(3):
    a.extend([int(s) for s in input().split()])
n = int(input())
for j in range(n):
    value = int(input())
    b.append(value)
    if value in a:
        a[a.index(value)] = '*'

if a[0] == a[1] == a[2] or a[0] == a[4] == a[8] or a[2] == a[4] == a[6] or a[1] == a[4] == a[7]:
    ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]="0"


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

Submission status: Wrong Answer

Solution code:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]=0


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

Submission status: Wrong Answer

Solution code:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b:
                Aij[j][k]='0'


if (Aij[0][0] == Aij[0][1] == Aij[0][2] == 0) or (Aij[1][0] == Aij[1][1] == Aij[1][2] == 0) or (Aij[2][0] == Aij[2][1] == Aij[2][2] == 0):
    print('Yes')
elif Aij[0][0]=='0' and Aij[0][1]=='0' and Aij[0][2]=='0':
    print('Yes')
elif Aij[1][0]=='0' and Aij[1][1]=='0' and Aij[1][2]=='0':
    print('Yes')
elif Aij[2][0]=='0' and Aij[2][1]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'


if (Aij[0][0] == Aij[0][1] == Aij[0][2] == 0) or (Aij[1][0] == Aij[1][1] == Aij[1][2] == 0) or (Aij[2][0] == Aij[2][1] == Aij[2][2] == 0):
    print('Yes')
elif Aij[0][0]=='0' and Aij[0][1]=='0' and Aij[0][2]=='0':
    print('Yes')
elif Aij[1][0]=='0' and Aij[1][1]=='0' and Aij[1][2]=='0':
    print('Yes')
elif Aij[2][0]=='0' and Aij[2][1]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'
if (Aij[0][0] == Aij[0][1] == Aij[0][2] == 0) or (Aij[1][0] == Aij[1][1] == Aij[1][2] == 0) or (Aij[2][0] == Aij[2][1] == Aij[2][2] == 0):
    print('Yes')
elif Aij[0][0]=='0' and Aij[0][1]=='0' and Aij[0][2]=='0':
    print('Yes')
elif Aij[1][0]=='0' and Aij[1][1]=='0' and Aij[1][2]=='0':
    print('Yes')
elif Aij[2][0]=='0' and Aij[2][1]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'                
if Aij[0].count('0')==3 or Aij[2].count('0')==3 or Aij[1].count('0')==3:
    print('Yes')
elif Aij[0][0]=='0' and Aij[0][1]=='0' and Aij[0][2]=='0':
    print('Yes')
elif Aij[1][0]=='0' and Aij[1][1]=='0' and Aij[1][2]=='0':
    print('Yes')
elif Aij[2][0]=='0' and Aij[2][1]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[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())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = -1
f = False
for i in range(3):
    for j in range(3):
        if (a[0][0] == a[0][1] == a[0][2]== -1) or (a[1][0] == a[1][1] == a[1][2]== -1) or (a[2][0] == a[2][1] == a[2][2]== -1):
            f = True
        elif (a[0][0] == a[1][0] == a[2][0] == -1) or (a[0][1] == a[1][1] == a[2][1] == -1) or (a[0][2] == a[1][2] == a[2][2] == -1):
            f = True
        elif (a[0][0] == a[1][1] == a[2][2] == -1) or (a[2][0] == a[1][1] == a[0][2] == -1):
            f = True
print(a)
if f:
    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())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] == -1
f = True
for i in range(3):
    for j in range(3):
        if (a[0][0] == a[0][1] == a[0][2]== -1) or (a[1][0] == a[1][1] == a[1][2]== -1) or (a[2][0] == a[2][1] == a[2][2]== -1):
            f = False
        elif (a[0][0] == a[1][0] == a[2][0] == -1) or (a[0][1] == a[1][1] == a[2][1] == -1) or (a[0][2] == a[1][2] == a[2][2] == -1):
            f = False
        elif (a[0][0] == a[1][1] == a[2][2] == -1) or (a[2][0] == a[1][1] == a[0][2] == -1):
            f = False
if f:
    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())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] == -1
f = True
for i in range(3):
    for j in range(3):
        if (a[0][0] == a[0][1] == a[0][2]== -1) or (a[1][0] == a[1][1] == a[1][2]== -1) or (a[2][0] == a[2][1] == a[2][2]== -1):
            f = False
        elif (a[0][0] == a[1][0] == a[2][0] == -1) or (a[0][1] == a[1][1] == a[2][1] == -1) or (a[0][2] == a[1][2] == a[2][2] == -1):
            f = False
        elif (a[0][0] == a[1][1] == a[2][2] == -1) or (a[2][0] == a[1][1] == a[0][2] == -1):
            f = False
if f:
    print('Yes')

Submission status: Wrong Answer

Solution code:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] == -1
f = True
for i in range(3):
    for j in range(3):
        if (a[0][0] == a[0][1] == a[0][2]== -1) or (a[1][0] == a[1][1] == a[1][2]== -1) or (a[2][0] == a[2][1] == a[2][2]== -1):
            f = False
        elif (a[0][0] == a[1][0] == a[2][0] == -1) or (a[0][1] == a[1][1] == a[2][1] == -1) or (a[0][2] == a[1][2] == a[2][2] == -1):
            f = False
        elif (a[0][0] == a[1][1] == a[2][2] == -1) or (a[2][0] == a[1][1] == a[2][0] == -1):
            f = False
if f:
    print('Yes')

Submission status: Wrong Answer

Solution code:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] == -1
f = True
for i in range(3):
    for j in range(3):
        if (a[0][0] and a[0][1] and a[0][2]== -1) or (a[1][0] and a[1][1] and a[1][2]== -1) or (a[2][0] and a[2][1] and a[2][2]== -1):
            f = False
        elif (a[0][0] and a[1][0] and a[2][0] == -1) or (a[0][1] and a[1][1] and a[2][1] == -1) or (a[0][2] and a[1][2] and a[2][2] == -1):
            f = False
        elif (a[0][0] and a[1][1] and a[2][2] == -1) or (a[2][0] and a[1][1] and a[2][0] == -1):
            f = False
if f:
    print('Yes')

Submission status: Wrong Answer

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

flag = []
flag.append([0]*3)
flag.append([0]*3)
flag.append([0]*3)

for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      flag[i][j] = 1
ans = "No"
for i in range(3):
  if A[i] == [1,1,1]:
    ans = "Yes"

x = [0,0,0]
y = [0, 0]
for i in range(3):
  y[0] += flag[i][i]
  y[1] += flag[i][2-i]
  for j in range(3):
  	x[j] += flag[i][j]
#print(x,y)
if 3 in x:
  ans = "Yes"
if 3 in y:
  ans = "Yes"
  
print(ans)

Submission status: Wrong Answer

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

check_a = [[0] * 3 for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            k = a[j].index(b)
            check_a[j][k] = 1

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

if a[0][0] == a[1][1] == a[2][2] == 1:
    ans = "Yes"
if a[0][2] == a[1][1] == a[2][0] == 1:
    ans = "Yes"

print(ans)

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()))
a = [a_1,a_2,a_3]
n = int(input())
for i in range(n):
  h = int(input())
  for j in range(3):
    for k in range(3):
      if(a[j][k]==h):
        a[j][k]=0
ans = "No"
for i in range(3):
  if(len(a[i]+[0])==1):
    ans = "Yes"
for i in range(3):
  if(len([a[0][i],a[1][i],a[2][i],[0]])==1):
    ans= "Yes"
if((a[0][0]==0)and(a[1][1]==a[2][2])and(a[0][0]==a[1][1]))or((a[0][2]==0)and(a[1][1]==a[2][0])and(a[0][2]==a[1][1])):
  ans = "Yes"
  
print(ans)

Submission status: Wrong Answer

Solution code:
arr = []
temp = []
for i in range(3):
    t = list(map(int, input().split()))
    arr.append(t)
    temp.extend(t)
    
n = int(input())
for i in range(n):
    a = int(input())
    if a in temp:
        for i in range(3):
            for j in range(3):
                if arr[i][j] == a:
                    arr[i][j] = 'X'
                elif arr[0][j] == arr[1][j] == arr[2][j] or  arr[0][0] == arr[1][1] == arr[2][2] or arr[0][2] == arr[1][1] == arr[2][0] or set(arr[i]) == {'X'}:
                    print('Yes')
                    exit()
        
print('No')

Submission status: Wrong Answer

Solution code:
arr = []
temp = []
for i in range(3):
    t = list(map(int, input().split()))
    arr.append(t)
    temp.extend(t)
    
n = int(input())
for i in range(n):
    a = int(input())
    if a in temp:
        for i in range(3):
            if set(arr[i]) == {'X'}:
                print('Yes')
                exit()
            for j in range(3):
                if arr[0][j] == arr[1][j] == arr[2][j] or  arr[0][0] == arr[1][1] == arr[2][2] or arr[0][2] == arr[1][1] == arr[2][0]:
                    print('Yes')
                    exit()
                elif arr[i][j] == a:
                    arr[i][j] = 'X'
        
print('No')

Submission status: Wrong Answer

Solution code:
arr = []
temp = []
for i in range(3):
    t = list(map(int, input().split()))
    arr.append(t)
    temp.extend(t)
    
n = int(input())
for i in range(n):
    a = int(input())
    if a in temp:
        for i in range(3):
            if len(set(arr[i])) == 1:
                print('Yes')
                exit()
            for j in range(3):
                if arr[0][j] == arr[1][j] == arr[2][j] or  arr[0][0] == arr[1][1] == arr[2][2] or arr[0][2] == arr[1][1] == arr[2][0]:
                    print('Yes')
                    exit()
                elif arr[i][j] == a:
                    arr[i][j] = 'X'
        
print('No')

Submission status: Wrong Answer

Solution code:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

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

N = int(input())
for n in range(N):
  b = int(input())
  if my_index(A1, b) is not False:
    A1[my_index(A1, b)] = -1
  if my_index(A2, b) is not False:
    A2[my_index(A2, b)] = -1
  if my_index(A3, b) is not False:
    A3[my_index(A3, b)] = -1

if (sum(A1) == -3) or (sum(A2) == -3) or (sum(A3) == -3):
  print("Yes")
elif (A1[0]+A2[0]+A3[0]==-3) or (A1[1]+A2[1]+A3[1]==-3) or (A1[1]+A2[1]+A3[1]==-3):
  print("Yes")
elif (A1[0]+A2[1]+A3[2]==-3) or (A1[2]+A2[1]+A3[0]==-3):
  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=[0]*N
for _ in range(N):
    B[_]=int(input())

G=[['.']*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            G[i][j]='#'
print(G)

if any(all(G[i][j]=='#' for i in range(3)) for j in range(3)) or \
   any(all(G[i][j]=='#' for j in range(3)) for i in range(3)) or \
   all(G[i][2-i]=='#' for i in range(3)) or \
   all(G[i][i]=='#' for i in range(3)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
listA = []
listB = []
for _ in range(3):
    listA.append(list(map(int, input().split())))
N = int(input())
for _ in range(N):
    listB.append(int(input()))
tate =  [0 , 0 , 0]
yoko = [0, 0, 0]
naname = [0, 0] 
for i in range(3):
    for j in range(3):
        if listA[i][j] in listB:
            tate[i] += 1
            yoko[i] += 1
            if i == j:
                naname[0] += 1
            if  i + j == 2:
                naname[1] += 1
if  3 in tate or 3 in yoko or 3 in naname:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "NO"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "YES"
  if seen[3] == "O" and seen[6] == "O":
    over = "YES"
  if seen[4] == "O" and seen[8] == "O":
    over = "YES"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "YES"
  if seen[2] == "O" and seen[5] == "O":
    over = "YES"
if seen[4] == "O":
  if seen[6] == "O" and seen[2] == "O":
    over = "YES"
  if seen[1] == "O" and seen[7] == "O":
    over = "YES"
  if seen[3] == "O" and seen[5] == "O":
    over = "YES"
print(over)

Submission status: Wrong Answer

Solution code:
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "NO"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "YES"
  elif seen[3] == "O" and seen[6] == "O":
    over = "YES"
  elif seen[4] == "O" and seen[8] == "O":
    over = "YES"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "YES"
  elif seen[2] == "O" and seen[5] == "O":
    over = "YES"
if seen[4] == "O":
  if seen[6] == "O" and seen[2] == "O":
    over = "YES"
  elif seen[1] == "O" and seen[7] == "O":
    over = "YES"
  elif seen[3] == "O" and seen[5] == "O":
    over = "YES"
print(over)

Submission status: Wrong Answer

Solution code:
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "NO"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "YES"
  elif seen[3] == "O" and seen[6] == "O":
    over = "YES"
  elif seen[4] == "O" and seen[8] == "O":
    over = "YES"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "YES"
  if seen[2] == "O" and seen[5] == "O":
    over = "YES"
if seen[4] == "O":
  if seen[2] == "O" and seen[6] == "O":
    over = "YES"
  elif seen[1] == "O" and seen[7] == "O":
    over = "YES"
  elif seen[3] == "O" and seen[5] == "O":
    over = "YES"
print(over)

Submission status: Wrong Answer

Solution code:
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = False
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = True
  elif seen[3] == "O" and seen[6] == "O":
    over = True
  elif seen[4] == "O" and seen[8] == "O":
    over = True
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = True
  if seen[2] == "O" and seen[5] == "O":
    over = True
if seen[4] == "O":
  if seen[2] == "O" and seen[6] == "O":
    over = True
  elif seen[1] == "O" and seen[7] == "O":
    over = True
  elif seen[3] == "O" and seen[5] == "O":
    over = True
if not over:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = False
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == seen[2] == "O":
    over = True
  elif seen[3] == seen[6] == "O":
    over = True
  elif seen[4] == seen[8] == "O":
    over = True
if seen[8] == "O":
  if seen[6] == seen[7] == "O":
    over = True
  if seen[2] == seen[5] == "O":
    over = True
if seen[4] == "O":
  if seen[2] == seen[6] == "O":
    over = True
  elif seen[1] == seen[7] == "O":
    over = True
  elif seen[3] == seen[5] == "O":
    over = True
if not over:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = False
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == seen[2] == "O":
    over = True
  elif seen[3] == seen[6] == "O":
    over = True
  elif seen[4] == seen[8] == "O":
    over = True
elif seen[4] == "O":
  if seen[2] == seen[6] == "O":
    over = True
  elif seen[1] == seen[7] == "O":
    over = True
  elif seen[3] == seen[5] == "O":
    over = True
elif seen[8] == "O":
  if seen[6] == seen[7] == "O":
    over = True
  if seen[2] == seen[5] == "O":
    over = True
if not over:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
board=[[0,0,0],[0,0,0],[0,0,0]]
board[0][0],board[0][1],board[0][2] = map(int,input().split())
board[1][0],board[1][1],board[1][2] = map(int,input().split())
board[2][0],board[2][1],board[2][2] = map(int,input().split())
for _ in range(int(input())):
    x = int(input())
    for i in range(3):
        for j in range(3):
            if board[i][j] == x:
                board[i][j] = "X"
found = "No"
if board[0][0] == "X":
    if board[0][1] == "X" and board[0][2] == "X":
        found = "Yes"
    elif board[1][0] == "X" and board[2][0] == "X":
        found = "Yes"
    elif board[1][1] == "X" and board[2][2] == "X":
        found = "Yes"
elif board[2][2] == "X":
    if board[0][2] == "X" and board[1][2] == "X":
        found = "Yes"
    elif board[2][0] == "X" and board[2][1] == "X":
        found = "Yes"
elif board[1][1] == "X":
    if board[0][2] == "X" and board[2][0] == "X":
        found = "YES"
    elif board[1][2] == "X" and board[1][0] == "X":
        found = "Yes"
    elif board[0][1] == "X" and board[0][2] == "X":
        found = "Yes"
print(found)

Submission status: Wrong Answer

Solution code:
bingo = []
sheet = set()
for _ in range(3):
  lst = [int(i) for i in input().split()]
  bingo.append(lst)
n = int(input())
for _ in range(n):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if bingo[i][j] == a:
        num = 3 * i + j
        sheet.add(num)
if 0 in sheet and 1 in sheet and 2 in sheet:
  print('Yes')
if 0 in sheet and 3 in sheet and 6 in sheet:
  print('Yes')
if 0 in sheet and 4 in sheet and 8 in sheet:
  print('Yes')
if 1 in sheet and 4 in sheet and 7 in sheet:
  print('Yes')
if 2 in sheet and 5 in sheet and 8 in sheet:
  print('Yes')
if 2 in sheet and 4 in sheet and 6 in sheet:
  print('Yes')
if 3 in sheet and 4 in sheet and 5 in sheet:
  print('Yes')
if 6 in sheet and 7 in sheet and 8 in sheet:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import itertools

bingo = []
sheet = set()
for _ in range(3):
  lst = [int(i) for i in input().split()]
  bingo.append(lst)
n = int(input())
for _ in range(n):
  a = int(input())
  for i in range(3):
    for j in range(3):
      if bingo[i][j] == a:
        num = 3 * i + j
        sheet.add(num)
flag = False
for v in itertools.combinations(sheet, 3):
  if (v[0] + v[1] + v[2]) % 3 == 0:
    flag = True
    break
if flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

n = int(input())

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

c = [[0]*3]*3

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

c = np.array(c)

if (max(c.sum(axis=0))==3) or (max(c.sum(axis=1))==3) or \
    (sum([c[i,i] for i in range(3)])==3) or (c[2,0]+c[1,1]+c[0,2]==3):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    bingo = [False]*9
    dic = dict()
    c = 0
    for _ in range(3):
        tmp = list(IL())
        for rep in tmp:
            dic[rep] = c
            c += 1
    n = I()
    for _ in range(n):
        b = I()
        idx = dic.get(b)
        if idx is None:
            continue
        bingo[idx] = True
    print(bingo)
    flag = False
    for i in range(0,3):
        for j in range(0,7,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return
        
    for i in range(0,7,3):
        for j in range(0,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return

    if (bingo[2] and bingo[4] and bingo[6]) or (bingo[0] and bingo[4] and bingo[8]):
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    bingo = [True]*9
    dic = dict()
    c = 0
    for _ in range(3):
        tmp = list(IL())
        for rep in tmp:
            dic[rep] = c
            c += 1
    n = I()
    for _ in range(n):
        b = I()
        idx = dic.get(b)
        if idx is None:
            continue
        bingo[idx] = True
    
    flag = False
    for i in range(0,3):
        for j in range(0,7,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return
        
    for i in range(0,7,3):
        for j in range(0,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return

    if (bingo[2] and bingo[4] and bingo[6]) or (bingo[0] and bingo[4] and bingo[8]):
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    bingo = [True]*9
    dic = dict()
    c = 0
    for _ in range(3):
        tmp = list(IL())
        for rep in tmp:
            dic[rep] = c
            c += 1
    n = I()
    for _ in range(n):
        b = I()
        idx = dic.get(b)
        if idx is None:
            continue
        bingo[idx] = True
    

    print(bingo)
    
    flag = False
    for i in range(0,3):
        for j in range(0,7,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return
        
    for i in range(0,7,3):
        for j in range(0,3):
            if not bingo[i+j]:
                break
        else:
            flag = True
    if flag:
        print('Yes')
        return

    if (bingo[2] and bingo[4] and bingo[6]) or (bingo[0] and bingo[4] and bingo[8]):
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    bingo = [0]*9
    dic = dict()
    c = 0
    for _ in range(3):
        tmp = list(IL())
        for rep in tmp:
            dic[rep] = c
            c += 1
    n = I()
    for _ in range(n):
        b = I()
        idx = dic.get(b)
        if idx is None:
            continue
        bingo[idx] = 1
    
    flag = False
    for i in range(0,3):
        for j in range(0,7,3):
            if bingo[i+j]==0:
                break
            else:
                flag = True
    if flag:
        print('Yes')
        return
        
    for i in range(0,7,3):
        for j in range(0,3):
            if bingo[i+j]==0:
                break
            else:
                flag = True
    if flag:
        print('Yes')
        return

    if bingo[2]==bingo[4]==bingo[6]==1 or bingo[0]==bingo[4]==bingo[8]==1:
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    solve()

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)]
hole = [[0]*3 for i in range(3)]
ans = "No" #初期値

for i in range(3):
  for j in range(3):
    for k in range(N):
      if A[i][j] == b[k]:
        hole[i][j] = 1 #穴あけ
  if A[i] == [1, 1, 1]:
    ans = "Yes" #横ビンゴ、i個目の要素（配列）はそろうので判別できる

flag_diag1 = 1
flag_diag2 = 1
for j in range(3):
  flag_vert = 1 #列ごとに初期化
  for i in range(3):
    flag_vert *= hole[i][j] #3つとも1のときだけ1
  if flag_vert ==1:
    ans = "Yes" #縦ビンゴ
  flag_diag1 *= hole[j][j] #＼
  flag_diag2 *= hole[j][2-j] #／
if flag_diag1 == 1 or flag_diag2 == 1:
  ans = "Yes" #斜めビンゴ
  
print(ans)