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:
A11,A12,A13 = map(int,input().split())
A21,A22,A23 = map(int,input().split())
A31,A32,A33 = map(int,input().split())
zennbu = {A11,A12,A13,A21,A22,A23,A31,A32,A33}
yoko1 = {A11,A12,A13}
yoko2 = {A21,A22,A23}
yoko3 = {A31,A32,A33}
tate1 = {A11,A21,A31}
tate2 = {A12,A22,A32}
tate3 = {A13,A23,A33}
naname1 = {A11,A22,A33}
naname2 = {A13,A22,A31}
N = int(input())
for i in range(N):
  b = int(input())
  if b in zennbu:
    yoko1.discard(b)
    yoko2.discard(b)
    yoko3.discard(b)
    tate1.discard(b)
    tate2.discard(b)
    tate3.discard(b)
    naname1.discard(b)
    naname2.discard(b)
if len(yoko1) ==0 or len(yoko2) ==0 or len(yoko2) ==0:
  print('Yes')
elif  len(tate1) ==0 or len(tate2) ==0 or len(tate3) ==0:
  print('Yes')
elif len(naname1) == 0 or len(naname2)==0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
a1 = stdin.readline().split()
a1 = [int(j) for i, j in enumerate(a1)]
a2 = stdin.readline().split()
a2 = [int(j) for i, j in enumerate(a2)]
a3 = stdin.readline().split()
a3 = [int(j) for i, j in enumerate(a3)]
a = a1 + a2 + a3

N = stdin.readline().rstrip()
N = int(N)
b = set()
for i in range(N):
    b.add(int(stdin.readline()))

bin_a = [None] * len(a)
for i, j in enumerate(b):
    if j in a:
        bin_a[a.index(j)] = 1

ans = 'No'
for i in range(3):
    if bin_a[i] == 1 and bin_a[i+3] == 1 and bin_a[i+6] == 1:
        ans = 'Yes'
for i in range(0,9,3):
    if bin_a[i] == 1 and bin_a[i+1] == 1 and bin_a[i+2] == 1:
        ans = 'Yes'
if bin_a[0] == 1 and bin_a[4] == 1 and bin_a[8] == 1:
    ans = 'Yes'
if bin_a[2] == 1 and bin_a[4] == 1 and bin_a[7] == 1:
    ans = 'Yes'
print(ans)

Submission status: Wrong Answer

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

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

x = [[False] * 3] * 3

for i in b:
    for j in range(3):
        if i in a[j]:
            x[j][a[j].index(i)] = True


flag = False

for i in range(3):
    if x[i][0] and x[i][1] and x[i][2]:
        flag = True
    elif x[0][i] and x[1][i] and x[2][i]:
        flag = True

if x[0][0] and x[1][1] and x[2][2]:
    flag = True
elif x[2][0] and x[1][1] and x[0][2]:
    flag = True

if flag:
    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 = list(map(int, input().split()))

x = [[False] * 3] * 3

for i in b:
    for j in range(3):
        if i in a[j]:
            x[j][a[j].index(i)] = True


flag = False

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

if x[0][0] and x[1][1] and x[2][2]:
    flag = True
elif x[2][0] and x[1][1] and x[0][2]:
    flag = True

if flag:
    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=[a1,a2,a3]
n=int(input())
q=[[0,0,0],[0,0,0],[0,0,0]]
b=[]
b=[int(input()) for i in range(n)]
for i in b:
    for c in range(3):
        for x in range(3):
            if b==a[c][x]:
                q[c][x]==1

result='No'
for t in range(3):
    if q[t][0]==q[t][1]==q[t][2]==1:
        result='Yes'
    elif q[0][t]==q[1][t]==q[2][t]==1:
        result='Yes'
    elif q[0][0]==q[1][1]==q[2][2]==1:
        result='Yes'
    elif q[0][2]==q[1][1]==q[2][0]==1:
        result='Yes'
print(result)

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(int(input())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return
    for i in range(3):
        if all(a[i][j] == 0 for j in range(3)) or all(a[j][i] == 0 for j in range(3)):
            print("Yes")
            return
    print("No")

Submission status: Wrong Answer

Solution code:
def B():
    mat = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if mat[i][j] == bingo:
                    mat[i][j] = 0
    for i in range(3):
        if all(mat[i][j] == 0 for j in range(3)):
            print('Yes')
            break
        if all(mat[j][i] == 0 for j in range(3)):
            print('Yes')
            break
    else:
        if mat[0][0] == mat[1][1] == mat[2][2] == 0 or\
                mat[0][2] == mat[1][1] == mat[2][0] == 0:
            print('Yes')
        else:
            print('No')
B()

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())
for i in range(N):
    b=int(input())
    if b==A:
        A=0
    if b==B:
        B=0
    if b==C:
        C=0
    if b==D:
        D=0
    if b==E:
        E=0
    if b==F:
        F=0
    if b==G:
        G=0
    if b==H:
        H=0
    if b==I:
        I=0



if A==0 and B==0 and C==0 or D==0 and E==0 and F==0 or G==0 and H==0 and i==0 or A==0 and D==0 and G==0 or B==0 and E==0 and H==0 or C==0 and F==0 and I==0 or A==0 and E==0 and I==0 or C==0 and E==0 and G==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    for i in range(3):
        if all(a[i][j] == 0 for j in range(3)):
            print("Yes")
            return
        if all(a[j][i] == 0 for j in range(3)):
            print("Yes")
            return
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return

    print("No")
B()

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    for i in range(3):
        if (a[i][0] == a[i][1] == a[i][2] == 0):
            print("Yes")
            return
        if (a[0][i] == a[1][i] == a[2][i] == 0):
            print("Yes")
            return
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return

    print("No")
B()

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return
    for i in range(3):
        if (a[i][0] == a[i][1] == a[i][2] == 0):
            print("Yes")
            return
        if (a[0][i] == a[1][i] == a[2][i] == 0):
            print("Yes")
            return
    print("No")
B()

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return
    for i in range(3):
        if (a[i][0] == a[i][1] == a[i][2] == 0) or (a[0][i] == a[1][i] == a[2][i] == 0):
            print("Yes")
            return
    print("No")
B()

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    import itertools
    a_list = list(itertools.chain.from_iterable(a))
    for bingo in b:
        if bingo in a_list:
            a_list[a_list.index(bingo)] = 0
    if (a_list[0+0] == a_list[3*1+1] == a_list[3*2+2] == 0) or (a_list[0+2] == a_list[3+1] == a_list[3*2] == 0):
        print("Yes")
        return
    for i in range(3):
        if (a_list[i*3+0] == a_list[i*3+1] == a_list[i*3+2] == 0) or (a_list[0+i] == a_list[3*1+i] == a_list[3*2+i] == 0):
            print("Yes")
            return
    print("No")
B()

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    bingo = [0]*9
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                bingo[i*3+j] = 1
    if (bingo[0+0] == bingo[3*1+1] == bingo[3*2+2] == 1) or (bingo[0+2] == bingo[3+1] == bingo[3*2] == 1):
        print("Yes")
        return
    for i in range(3):
        if (bingo[i*3+0] == bingo[i*3+1] == bingo[i*3+2] == 1) or (bingo[0+i] == bingo[3*1+i] == bingo[3*2+i] == 1):
            print("Yes")
            return
    print("No")
B()

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())
L = []
L.append({a, b, c})
L.append({d, e, f})
L.append({g, h, i})
L.append({a, d, g})
L.append({b, e, h})
L.append({c, f, i})
L.append({a, e, i})
L.append({c, f, g})
N = int(input())
B = {int(input()) for i in range(N)}
if any(l <= B for l in L):
  print("Yes")
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())
L = []
L.append({a, b, c})
L.append({d, e, f})
L.append({g, h, i})
L.append({a, d, g})
L.append({b, e, h})
L.append({c, f, i})
L.append({a, e, i})
L.append({c, f, i})
N = int(input())
B = {int(input()) for i in range(N)}
if any(l <= B for l in L):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

for i in range(N):
    b = int(input())
    for j in range(3):
        A[j] = ["$" if num == b else num for num in A[j]]

if ["$"]*3 in A:
    print("Yes")
elif any( [A[i][j] for j in range(3)] == ["$"]*3 for i in range(3) ):
    print("Yes")
elif [A[0][0], A[1][1], A[2][2]] == ["$"]*3 \
            or [A[0][2], A[1][1], A[2][0]] == ["$"]*3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math
def main():
    a = list(map(int, input().split()))
    a.extend(list(map(int, input().split())))
    a.extend(list(map(int, input().split())))
    n = int(input())
    for _ in range(n):
        x = int(input())
        a = [True if i == x else i for i in a]
    a = [False if i != True else True for i in a]
    if all(a[0:3]) or all(a[3:6]) or all(a[6:]):
        print("Yes")
    elif all(a[0::3]) or all(a[2::3]) or all(a[3::3]):
        print("Yes")
    elif all(a[0::4]) or all(a[2::4]):
        print("Yes")
    else:
        print("No")
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for x in b:
    for i in range(3):
        for j in range(3):
            if x == a[i][j]:
                a[i][j] = -1
ans = 'No'
for i in range(3):
    if a[i][0] == a[i][1] and a[i][1] == a[i][2]:
        ans = 'Yes'

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

if a[0][2] == -1 and a[1][1] == -1 and a[2][0] == -1:
    ans = 'Yes'

if a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
L = []
L.append(list(map(int, input().split())))
L.append(list(map(int, input().split())))
L.append(list(map(int, input().split())))
L.append([L[0][0], L[1][0], L[2][0]])
L.append([L[0][1], L[1][1], L[2][1]])
L.append([L[0][2], L[1][2], L[2][2]])
L.append([L[0][0], L[1][1], L[2][2]])
L.append([L[0][2], L[1][1], L[2][0]])
N = int(input())
B = [int(input()) for i in range(N)]
if any(l in B for l in L):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
L = []
L.append(list(map(int, input().split())))
L.append(list(map(int, input().split())))
L.append(list(map(int, input().split())))
L.append([L[0][0], L[1][0], L[2][0]])
L.append([L[0][1], L[1][1], L[2][1]])
L.append([L[0][2], L[1][2], L[2][2]])
L.append([L[0][0], L[1][1], L[2][2]])
L.append([L[0][2], L[1][1], L[2][0]])
N = int(input())
B = [int(input()) for i in range(N)]
if any(B > l for l in L):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
L = []
L.append(list(map(int, input().split())))
L.append(list(map(int, input().split())))
L.append(list(map(int, input().split())))
L.append([L[0][0], L[1][0], L[2][0]])
L.append([L[0][1], L[1][1], L[2][1]])
L.append([L[0][2], L[1][2], L[2][2]])
L.append([L[0][0], L[1][1], L[2][2]])
L.append([L[0][2], L[1][1], L[2][0]])
N = int(input())
B = [int(input()) for i in range(N)]
if any(B >= l for l in L):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def inlt():
    return(list(map(int, input().split())))


def inp():
    return(int(input()))


A = []
for t in range(3):
    A.append(inlt())

n = inp()
for t in range(n):
    b = inp()
    # mark the position of b
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0
res = "No"
# see row wise:
for i in range(3):
    s = 0
    for j in range(3):
        s += A[i][j]
    if s == 0:
        res = "Yes"
        break
# see column wise
for i in range(3):
    s = 0
    for j in range(3):
        s += A[j][i]
    if s == 0:
        res = "Yes"
        break
# see diagonal
s = 0
for i in range(3):
    for j in range(3):
        if i == j:
            s += A[j][i]
if s == 0:
    res = "Yes"

print(res)

Submission status: Wrong Answer

Solution code:
def inlt():
    return(list(map(int, input().split())))


def inp():
    return(int(input()))


A = []
for t in range(3):
    A.append(inlt())

n = inp()
for t in range(n):
    b = inp()
    # mark the position of b
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

res = "No"
# see row wise:
for row in A:
    if sum(row) == 0:
        res = "Yes"
        break
# see column wise
for i in range(3):
    s = 0
    for j in range(3):
        s += A[j][i]
    if s == 0:
        res = "Yes"
        break
# see diagonal
s = 0
for i in range(3):
    for j in range(3):
        if i == j:
            s += A[j][i]
if s == 0:
    res = "Yes"

print(res)

Submission status: Wrong Answer

Solution code:
a =[list(map(int, input().split())) for i in range(3)] 
n=int(input())
ans = 'No'
for i in range(n):
    d = int(input())
    for i in range(3):
        for j in range(3):
            if d == a[i][j]:
                a[i][j]=0

if (a[0][0] == 0 and a[1][1] == 0 and a[2][2]==0) or (a[0][2] == 0 and a[1][1] == 0 and a[2][0]==0):
    ans = 'Yes'
else: 
    for l in a:
        if sum(l)==0:
            ans = 'Yes'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
a =[list(map(int, input().split())) for i in range(3)] 
n=int(input())
ans = 'No'
for i in range(n):
    d = int(input())
    for i in range(3):
        for j in range(3):
            if d == a[i][j]:
                a[i][j]=0

if a[0][0] == 0 and a[1][1] == 0 and a[2][2]==0:
    ans = 'Yes'
else: 
    for l in a:
        if sum(l)==0:
            ans = 'Yes'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
a1x = [int(x) for x in input().split(' ')]
a2x = [int(x) for x in input().split(' ')]
a3x = [int(x) for x in input().split(' ')]

sheet = [a1x, a2x, a3x]

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

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

def solve(n, sheet, numbers):
    for number in numbers:
        for row in range(3):
            for column in range(3):
                if sheet[row][column] == number:
                    sheet[row][column] = "X"

    if checkRow(sheet) or checkColumn(sheet) or checkDiagonal(sheet):
        print("Yes")
    else:
        print("No")

def checkRow(sheet):
    for row in range(3):
        marked = 0
        for column in range(3):
            if sheet[row][column] == "X":
                marked += 1
        if marked == 3:
            return True
    
    return False
            
def checkColumn(sheet):
    for row in range(3):
        marked = 0
        for column in range(3):
            if sheet[column][row] == "X":
                marked += 1
        if marked == 3:
            return True
    
    return False

def checkDiagonal(sheet):
    marked = 0
    for i in range(3):
        if sheet[i][i] == "X":
            marked += 1

    if marked == 3:
        return True
    else:
        return False
    

solve(n, sheet, numbers)

Submission status: Wrong Answer

Solution code:
A =[]
A_bool = [False]*9
for i in range(3):
    A += list(map(int, input().split()))

N = int(input())

for j in range(N):
    b = int(input())
    if b in A:
        A_bool[A.index(b)] = True

if A[0:3] == 3 or A[3:6] == 3 or A[6:9] == 3 or A[0:8:3] == 3 or A[1:8:3] == 3 or A[2:8:3] == 3 or A[0:9:4] == 3 or A[2:7:2]==3:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A =[]
A_bool = [False]*9
for i in range(3):
    A += list(map(int, input().split()))

N = int(input())

for j in range(N):
    b = int(input())
    if b in A:
        A_bool[A.index(b)] = True

        
combinations = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]

for combination in combinations:
    if A[combination[0]] + A[combination[1]] + A[combination[2]] == 3:
        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 range(3):
    for j in range(3):
        if a[i][j] in b:
             a[i][j] = 0

import numpy as np 

arr = np.array(a)

answer = "No"
if 0 in arr.sum(axis=0) or 0 in arr.sum(axis=0):
    answer = "Yes"
elif arr.diagonal().sum() == 0 or np.fliplr(arr).diagonal().sum() == 0: # 行列左右反転　fliplr()
    answer = "Yes"

print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))

bingo = np.array([A_1, A_2, A_3])
N = int(input())
for i in range(N):
    bingo[bingo == int(input())] = 0

def check():
    for i in range(3):
        if bingo[i][0] == 0 and bingo[i][1] == 0 and bingo[i][2] == 0:
            return True
        if bingo[0][i] == 0 and bingo[1][i] == 0 and bingo[2][i] == 0:
            return True
    if bingo[0][0] == 0 and bingo[1][1] == 0 and bingo[2][2] == 0:
        return True
    if bingo[0][2] == 0 and bingo[1][i] == 0 and bingo[2][0] == 0:
        return True

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

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0


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

Submission status: Wrong Answer

Solution code:
def check(T):
    column = any([all( [T[i][j] for j in range(3)] ) for i in range(3)])
    row = any([all( [T[j][i]for j in range(3)] ) for i in range(3)])
    diagonal = all( [T[i][i] for i in range(3)] )
    return row or column or diagonal

a = 3
grid =[[0]*a for i in range(a)]

d = {}
for i in range(3):
    row = list(map(int,input().split()))
    for j in range(3):
        d[row[j]] = (i,j)


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

    if p in d.keys():
        x,y = d[p]
        grid[x][y] = 1

print( "Yes" if check(grid) else "No")

Submission status: Wrong Answer

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

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

ans=0
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    ans=1
  elif a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    ans=1

if a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
  ans=1

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

Submission status: Wrong Answer

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

for i in range(n):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:
        a[j][k]=0
print(a)
        
ans=0
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    ans=1
  elif a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    ans=1

if a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
  ans=1

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

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    bingo = [0]*9
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                bingo[i*3+j] = 1
    if (bingo[0] == bingo[3+1] == bingo[3*2+2] == 1) or (bingo[2] == bingo[3+1] == bingo[3*2] == 1):
        print("Yes")
        return
    for i in range(3):
        if (bingo[i*3+0] == bingo[i*3+1] == bingo[i*3+2] == 1) or (bingo[0+i] == bingo[3*1+i] == bingo[3*2+i] == 1):
            print("Yes")
            return
    print("No")
B()

Submission status: Wrong Answer

Solution code:
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [list(map(int,input().split())) for i in range(n)]
    import itertools
    a_list = list(itertools.chain.from_iterable(a))
    if a_list[0] in b and a_list[4] in b and a_list[8] in b:
        print("Yes")
        return
    for i in range(3):
        row = True
        col = True
        dig = True
        for j in range(3):
            if row and a_list[i*3+j] not in b:
                row = False
            if col and a_list[j*3+i] not in b:
                col = False
        if row or col:
            print("Yes")
            return
    print("No")
B()

Submission status: Wrong Answer

Solution code:
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
list3 = list(map(int, input().split()))
n = int(input())
num_list = []
for i in range(n):
    b = int(input())
    num_list.append(b)
for num in num_list:
    if num in list1:
        x = list1.index(num)
        list1.pop(x)
        list1.insert(x, 'bingo')
    if num in list2:
        x = list2.index(num)
        list2.pop(x)
        list2.insert(x, 'bingo')
    if num in list3:
        x = list3.index(num)
        list3.pop(x)
        list3.insert(x, 'bingo')
result = 'No'
if list1[0] == list1[1] == list1[2] == 'bingo':
    result = 'Yes'
if list2[0] == list2[1] == list2[2] == 'bingo':
    result = 'Yes'
if list3[0] == list3[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[0] == list3[0] == 'bingo':
    result = 'Yes'
if list1[1] == list2[1] == list3[1] == 'bingo':
    result = 'Yes'
if list1[2] == list2[2] == list3[2] == 'bingo':
    result = 'Yes'
if list1[0] == list2[1] == list3[2] == 'bingo':
    result = 'Yes'
if list1[2] == list2[1] == list3[0] == 'bingo':
    result = 'Yes'
print(list1)
print(list2)
print(list3)
print(result)

Submission status: Wrong Answer

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

for b in range(N):
    if b in A:
        A[A.index(b)] = 0
    elif A[0] + A[1] + A[2] == 0:
        print("Yes")
        exit()
    elif A[3] + A[4] + A[5] == 0:
        print("Yes")
        exit()
    elif A[6] + A[7] + A[8] == 0:
        print("Yes")
        exit()
    elif A[0] + A[3] + A[6] == 0:
        print("Yes")
        exit()
    elif A[1] + A[4] + A[7] == 0:
        print("Yes")
        exit()
    elif A[2] + A[5] + A[8] == 0:
        print("Yes")
        exit()
    elif A[0] + A[4] + A[8] == 0:
        print("Yes")
        exit()
    elif A[2] + A[4] + A[6] == 0:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        for k in range(N):
            #print(A[i][j], B[k])
            if A[i][j] == B[k]:
                result[i][j] = 1
                break
            else:
                result[i][j] = 0

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

Submission status: Wrong Answer

Solution code:
def main():
    a1_lis = list(map(int, input().split()))
    a2_lis = list(map(int, input().split()))
    a3_lis = list(map(int, input().split()))

    n = int(input())
    b_lis = []
    for _ in range(n):
        b_lis.append(int(input()))
    
    if a1_lis[0] in b_lis and a1_lis[1] in b_lis and a1_lis[2] in b_lis:
        print('Yes')
        exit()
    if a2_lis[0] in b_lis and a2_lis[1] in b_lis and a2_lis[2] in b_lis:
        print('Yes')
        exit()
    if a3_lis[0] in b_lis and a3_lis[1] in b_lis and a3_lis[2] in b_lis:
        print('Yes')
        exit()
    if a1_lis[0] in b_lis and a2_lis[1] in b_lis and a3_lis[2] in b_lis:
        print('Yes')
        exit()
    if a3_lis[0] in b_lis and a2_lis[1] in b_lis and a1_lis[2] in b_lis:
        print('Yes')
        exit()
    else:
        print("No")
        


    


if __name__ == "__main__":
    main()

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 k == a[i][j]:
          a[i][j] = 101
          break
      
if a[0] == [101,101,101] or a[1] == [101,101,101] or a[2] == [101,101,101]:
  print('Yes')
  exit()
elif (a[0][0]==101 and a[1][0] ==101 and a[2][0] == 101) or (a[0][1]==101 and a[1][1] ==101 and a[2][1] == 101) and (a[0][2]==101 and a[1][2] ==101 and a[2][2] == 101):
  print('Yes')
  exit()
elif (a[0][0]==101 and a[1][1] ==101 and a[2][2] == 101) or (a[0][2]==101 and a[1][1] ==101 and a[2][0] == 101):
  print('Yes')
  exit()
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import itertools
import math
import fractions
import functools


l = [list(map(int, input().split())),list(map(int, input().split())),list(map(int, input().split()))]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

ij = []
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == l[j][k]:
                ij.append([j,k])

for i in range(3):
    count = 0
    for j in range(3):
        for k in range(len(ij)):
            if ij[k] == [i,j]:
                count += 1
        if count >= 3:
            print("Yes")
            quit()

for i in range(3):
    count = 0
    for j in range(3):
        for k in range(len(ij)):
            if ij[k] == [j,i]:
                count += 1
        if count >= 3:
            print("Yes")
            quit()

for i in range(3):
    count = 0
    for j in range(len(ij)):
        if ij[k] == [i,i]:
            count += 1
    if count >= 3:
        print("Yes")
        quit()

count = 0
for i in range(len(ij)):
    if ij[i] == [0,2] or ij[i] == [1,1] or ij[i] == [2,0]:
        count += 1
if count >= 3:
    print("Yes")
    quit()

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()))
a = a_1 + a_2 + a_3
aa = [0] * 9
n = int(input())
for i in range(n):
    b = int(input())
    a_dash = map(lambda x: x-b, a)
    try:
        index = a.index(0)
        aa[index] = 1
    except ValueError:
        pass
print(aa)
if aa[0] == aa[1] == aa[2] == 1:
    print('Yes')
elif aa[3] == aa[4] == aa[5] == 1:
    print('Yes')
elif aa[6] == aa[7] == aa[8] == 1:
    print('Yes')
elif aa[0] == aa[3] == aa[6] == 1:
    print('Yes')
elif aa[1] == aa[4] == aa[7] == 1:
    print('Yes')
elif aa[2] == aa[5] == aa[8] == 1:
    print('Yes')
elif aa[0] == aa[4] == aa[8] == 1:
    print('Yes')
elif aa[2] == aa[4] == aa[6] == 1:
    print('Yes')
else:
    print('No')