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:
import itertools
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = list(itertools.chain.from_iterable([a1, a2, a3]))

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

for i in b:
    a = [x if x != i else 0 for x in a]

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

Submission status: Wrong Answer

Solution code:
import itertools
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = list(itertools.chain.from_iterable([a1, a2, a3]))

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

for i in b:
    for j in range(9):
        if i == a[j]:
            a[j] = 0

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

Submission status: Wrong Answer

Solution code:
import itertools
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = list(itertools.chain.from_iterable([a1, a2, a3]))

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

for i in b:
    for j in range(9):
        if i == a[j]:
            a[j] = 0

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

Submission status: Wrong Answer

Solution code:
import itertools
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = list(itertools.chain.from_iterable([a1, a2, a3]))

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

for i in b:
  for j in range(9):
    if i == a[j]:
      a[j] = 0

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

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = {int(input()) for _ in range(N)}

h1 = {A11, A12, A13}
h2 = {A21, A22, A23}
h3 = {A31, A32, A33}
v1 = {A11, A21, A31}
v2 = {A12, A22, A32}
v3 = {A13, A23, A33}
c1 = {A11, A22, A33}
c2 = {A13, A22, A31}

if len(h1 & B)==3 or len(h2 & B)==3 or len(h3 & B)==3 or len(v1 & B)==3 or len(v2 & B)==3 or len(v3 & B)==3 or (c1 & B)==3 or len(c2 & B)==3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = [int(input()) for _ in range(N)]

h1 = [A11, A12, A13]
h2 = [A21, A22, A23]
h3 = [A31, A32, A33]
v1 = [A11, A21, A31]
v2 = [A12, A22, A32]
v3 = [A13, A23, A33]
c1 = [A11, A22, A33]
c2 = [A13, A22, A31]

if h1 <= B or h2 <= B or h3 <= B or v1 <= B or v2 <= B or v3 <= B or c1 <= B or c2 <= B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = [int(input()) for _ in range(N)]

h1 = [A11, A12, A13]
h2 = [A21, A22, A23]
h3 = [A31, A32, A33]
v1 = [A11, A21, A31]
v2 = [A12, A22, A32]
v3 = [A13, A23, A33]
c1 = [A11, A22, A33]
c2 = [A13, A22, A31]



if h1 >= B or h2 >= B or h3 >= B or v1 >= B or v2 >= B or v3 >= B or c1 >= B or c2 >= B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = [int(input()) for _ in range(N)]

h1 = [A11, A12, A13]
h2 = [A21, A22, A23]
h3 = [A31, A32, A33]
v1 = [A11, A21, A31]
v2 = [A12, A22, A32]
v3 = [A13, A23, A33]
c1 = [A11, A22, A33]
c2 = [A13, A22, A31]

print(h3 >= B)
print(h3)
print(B)


if h1 >= B or h2 >= B or h3 >= B or v1 >= B or v2 >= B or v3 >= B or c1 >= B or c2 >= B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = [int(input()) for _ in range(N)]

h1 = [A11, A12, A13]
h2 = [A21, A22, A23]
h3 = [A31, A32, A33]
v1 = [A11, A21, A31]
v2 = [A12, A22, A32]
v3 = [A13, A23, A33]
c1 = [A11, A22, A33]
c2 = [A13, A22, A31]


if h1 <= B or h2 <= B or h3 <= B or v1 <= B or v2 <= B or v3 <= B or c1 <= B or c2 <= B:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
A11, A12, A13 = map(int, input().split())
A21, A22, A23 = map(int, input().split())
A31, A32, A33 = map(int, input().split())
N = int(input())
B = [int(input()) for _ in range(N)]

h1 = [A11, A12, A13]
h2 = [A21, A22, A23]
h3 = [A31, A32, A33]
v1 = [A11, A21, A31]
v2 = [A12, A22, A32]
v3 = [A13, A23, A33]
c1 = [A11, A22, A33]
c2 = [A13, A22, A31]


condition = h1 or h2 or h3 or v1 or v2 or v3 or c1 or c2

if h1 <= B or h2 <= B or h3 <= B or v1 <= B or v2 <= B or v3 <= B or c1 <= B or c2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# Bingo
A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(input())
for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = -1
        
# check
diag = (sum(A[0::4]) == -3) | (sum(A[2:8:2]) == -3)
rows = (sum(A[:3]) == -3) | (sum(A[3:6]) == -3) | (sum(A[6:]) == -3)
cols = (sum(A[:7:3]) == -3) | (sum(A[1:8:3]) == -3) | (sum(A[2::3]) == -3)
ans = diag | rows | cols
print(A)
print(['No', 'Yes'][ans])

Submission status: Wrong Answer

Solution code:
# Bingo
A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(input())
for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = -1
        
# check
diag = (sum(A[0::4]) == -3) | (sum(A[2:8:2]) == -3)
rows = (sum(A[:3]) == -3) | (sum(A[4:6]) == -3) | (sum(A[6:]) == -3)
cols = (sum(A[:7:3]) == -3) | (sum(A[1:8:3]) == -3) | (sum(A[2::3]) == -3)
ans = diag | rows | cols
print(['No', 'Yes'][ans])

Submission status: Wrong Answer

Solution code:
# Bingo
A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(input())
for _ in range(N):
    b = int(input())
    if b in A:
        A[A.index(b)] = -1
        
# check
diag1 = (A[0] == -1) & (A[4] == -1) & (A[8] == -1)
diag2 = (A[2] == -1) & (A[4] == -1) & (A[6] == -1)
rows = (sum(A[:3]) == -3) | (sum(A[4:6]) == -3) | (sum(A[6:]) == -3)
cols = (sum(A[:7:3]) == -3) | (sum(A[1:8:3]) == -3) | (sum(A[2::3]) == -3)
ans = diag1 | diag2 | rows | cols
print(['No', 'Yes'][ans])

Submission status: Wrong Answer

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

    for i in range(N):
        B.append(int(input())) 
    
    for i in range(3):
        cnt = 0
        for j in range(3):
            if A[i][j] in B:
                cnt += 1
        if cnt==3:
            print('Yes')
            quit()
            
    for i in range(3):
        cnt = 0
        for j in range(3):
            if A[j][i] in B:
                cnt += 1
        if cnt==3:
            print('Yes')

    if A[0][0] in B and A[1][1] in B and A[2][2] in B:
        print('Yes')
        quit()
    
    if A[0][2] in B and A[1][1] in B and A[2][0] in B:
        print('Yes')
        quit()
    
    print('No')

Submission status: Wrong Answer

Solution code:
l = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())
bi = []

for _ in range(n):
  m = int(input())
  c = 0
  for i in l:
      if i.count(m) > 0:
        bi.append([c, i.index(m)])
      c += 1

i = 0
s1, s2, s3, s4 = 0, 0, 0, 0
bi = list(map(list, set(map(tuple, bi))))
for b in bi:
  for x in range(3):
    for y in range(3):
      if b == [x, y]:
        s1 += 1
      if b == [y, x]:
        s2 += 1
      if b == [x, x]:
        s3 += 1
      if b == [2-x, x]:
        s4 += 1

if s1 == 3 or s2 == 3 or s3 == 3 or s4 == 3:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())
bi = []

for _ in range(n):
  m = int(input())
  c = 0
  for i in l:
      if i.count(m) > 0:
        bi.append([c, i.index(m)])
      c += 1

i = 0
s1, s2, s3, s4 = 0, 0, 0, 0
bi = list(map(list, set(map(tuple, bi))))
print(bi)
for b in bi:
  for x in range(3):
    for y in range(3):
      if b == [x, y]:
        s1 += 1
      if b == [y, x]:
        s2 += 1
      if b == [x, x]:
        s3 += 1
      if b == [2-x, x]:
        s4 += 1

if s1 == 3 or s2 == 3 or s3 == 3 or s4 == 3:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())
bi = []

for _ in range(n):
  m = int(input())
  c = 0
  for i in l:
      if i.count(m) > 0:
        bi.append([c, i.index(m)])
      c += 1

i = 0
s1, s2, s3, s4 = 0, 0, 0, 0
bi = list(map(list, set(map(tuple, bi))))
for b in bi:
  for x in range(3):
    if b == [x, 0]:
      s1 += 1
    if b == [0, x]:
      s2 += 1
    if b == [x, x]:
      s3 += 1
    if b == [2-x, x]:
      s4 += 1

if s1 == 3 or s2 == 3 or s3 == 3 or s4 == 3:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
l = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())
bi = []

for _ in range(n):
  m = int(input())
  c = 0
  for i in l:
      if i.count(m) > 0:
        bi.append([c, i.index(m)])
      c += 1

i = 0
s1, s2, s3, s4 = 0, 0, 0, 0
for x in range(3):
  for b in bi:
    if b == [x, 0]:
      s1 += 1
    if b == [0, x]:
      s2 += 1
    if b == [x, x]:
      s3 += 1
    if b == [2-x, x]:
      s4 += 1

if s1 == 3 or s2 == 3 or s3 == 3 or s4 == 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())

for n in range(N):
    B = int(input())

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


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

    elif A[0][i] == 0 & A[1][i] == 0 & A[2][i] == 0:
        print("Yes")
        exit()

if A[0][0] == 0 & A[1][1] == 0 & A[2][2] == 0:
    print("Yes")

elif A[0][2] == 0 & A[1][1] == 0 & 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())

for n in range(N):
    B = int(input())

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


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

    if A[0][i] == 0 & A[1][i] == 0 & A[2][i] == 0:
        print("Yes")
        exit()

if A[0][0] == 0 & A[1][1] == 0 & A[2][2] == 0:
    print("Yes")

elif A[0][2] == 0 & A[1][1] == 0 & A[2][0] == 0:
    print("Yes")

else:
    print("No")

Submission status: Wrong Answer

Solution code:
def check(a):
    m = [-1, -1, -1]
    if [a[0][0], a[1][1],a[2][2]] == m:
        print("Yes")
        return
    if [a[0][2], a[1][1], a[2][0]] == m:
        print("Yes")
        return
    for i in range(3):
        if a[i] == m:
            print("Yes")
            return
        elif [r[i] for r in a] == m:
            print("Yes")
            return
    print("No")
    return

a=[list(map(int,input().split()))for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
for i in range(n):
    for y,row in enumerate(a):
        try:
            x=row.index(b[i])
            a[x][y]=-1
        except ValueError:
            pass
check(a)

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())
s=set()
for _ in range(N):
  b=int(input())
  if b in A:
    s|={A.index(b)}
bingo=[{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,5,8},{3,4,5},{6,7,8}]
print(["No","Yes"][any(s>=b for b in bingo)])

Submission status: Wrong Answer

Solution code:
import sys
import itertools

def resolve(in_):
    A = tuple(map(int, itertools.chain.from_iterable(line.split() for line in itertools.islice(in_, 3))))
    assert len(A) == 9
    C = [False] * 9
    N = int(next(in_))
    # B = tuple(map(int, itertools.islice(in_, N)))
    B = frozenset(map(int, itertools.islice(in_, N)))

    for i, a in enumerate(A):
        if a in B:
            C[i] = True
    # print(f'{A=} {C=}')
    
    b = any(all(line) for line in itertools.chain(
        ((C[i * 3], C[i * 3 + 1], C[i * 3 + 2]) for i in range(2)),
        ((C[i], C[i + 3], C[i + 6]) for i in range(2)),
        ((C[0], C[4], C[8]), (C[2], C[4], C[6])),
    ))
    return 'Yes' if b else 'No'


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import itertools

def resolve(in_):
    A = tuple(map(int, itertools.chain.from_iterable(line.split() for line in itertools.islice(in_, 3))))
    assert len(A) == 9
    C = [False] * 9
    N = int(next(in_))
    # B = tuple(map(int, itertools.islice(in_, N)))
    B = frozenset(map(int, itertools.islice(in_, N)))

    for i, a in enumerate(A):
        if a in B:
            C[i] = True
    
    b = any(any(line) for line in itertools.chain(
        ((C[i * 3], C[i * 3 + 1], C[i * 3 + 2]) for i in range(2)),
        ((C[i], C[i + 3], C[i + 6]) for i in range(2)),
        ((C[0], C[4], C[8]), (C[2], C[4], C[6])),
    ))
    return 'Yes' if b else 'No'


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


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())
a = []

for i in range(N):
    a.append(int(input()))
   
    if A1[0] == a[i]:
        A1[0] = True
    elif a[i] == A1[1]:
        A1[1] = True
    elif a[i] == A1[2]:
        A1[2] = True
    elif a[i] == A2[0]:
        A2[0] = True
    elif a[i] == A2[1]:
        A2[1] = True
    elif a[i] == A2[2]:
        A2[2] = True
    elif a[i] == A3[0]:
        A3[0] = True
    elif a[i] == A3[1]:
        A3[1] = True
    elif a[i] == A3[2]:
        A3[2] = True


if A1[0] == True and A1[1] == True and A1[2] == True:
    print("yes")
elif A1[0] == True and A2[0] == True and A3[0] == True:
    print("yes")
elif A1[0] == True and A2[1] == True and A3[2] == True:
    print("yes")
elif A1[1] == True and A2[1] == True and A3[1] == True:
    print("yes")
elif A1[2] == True and A2[2] == True and A3[2] == True:
    print("yes")
elif A2[0] == True and A2[1] == True and A2[2] == True:
    print("yes")
elif A3[0] == True and A3[1] == True and A3[2] == True:
    print("yes")
elif A1[2] == True and A2[1] == True and A3[0] == True:
    print("Yes")
    
else:             
    print("No")

Submission status: Wrong Answer

Solution code:
A11,A12,A13 = input().split()
A21,A22,A23 = input().split()
A31,A32,A33 = input().split()

N = int(input())
a = list()

for i in range(N):
    a.append(input())
    if a[0+i] == A11:
        A11 = True
    elif a[0+i] == A12:
        A12 = True
    elif a[0+i] == A13:
        A13 = True
    elif a[0+i] == A21:
        A21 = True
    elif a[0+i] == A22:
        A22 = True
    elif a[0+i] == A23:
        A23 = True
    elif a[0+i] == A31:
        A31 = True
    elif a[0+i] == A32:
        A32 = True
    elif a[0+i] == A33:
        A33 = True


if A11 == True and A12 == True and A13 == True:
    print("yes")
elif A11 == True and A21 == True and A31 == True:
    print("yes")
elif A11 == True and A22 == True and A33 == True:
    print("yes")
elif A12 == True and A22 == True and A32 == True:
    print("yes")
elif A13 == True and A23 == True and A33 == True:
    print("yes")
elif A21 == True and A22 == True and A23 == True:
    print("yes")
elif A31 == True and A32 == True and A33 == True:
    print("yes")
elif A13 == True and A22 == True and A31 == True:
    print("Yes")
    
else:             
    print("No")

Submission status: Wrong Answer

Solution code:

A11,A12,A13 = input().split()
A21,A22,A23 = input().split()
A31,A32,A33 = input().split()

N = int(input())
a = list()

for i in range(N):
    a.append(input())
    if a[0+i] == A11:
        A11 = True
    elif a[0+i] == A12:
        A12 = True
    elif a[0+i] == A13:
        A13 = True
    elif a[0+i] == A21:
        A21 = True
    elif a[0+i] == A22:
        A22 = True
    elif a[0+i] == A23:
        A23 = True
    elif a[0+i] == A31:
        A31 = True
    elif a[0+i] == A32:
        A32 = True
    elif a[0+i] == A33:
        A33 = True


if A11 == True and A12 == True and A13 == True:
    print("yes")
elif A11 == True and A21 == True and A31 == True:
    print("yes")
elif A11 == True and A22 == True and A33 == True:
    print("yes")
elif A12 == True and A22 == True and A32 == True:
    print("yes")
elif A13 == True and A23 == True and A33 == True:
    print("yes")
elif A21 == True and A22 == True and A23 == True:
    print("yes")
elif A31 == True and A32 == True and A33 == True:
    print("yes")
elif A13 == True and A22 == True and A31 == True:
    print("yes")
    
else:             
    print("no")

Submission status: Wrong Answer

Solution code:
A = [[j for j in list(map(int, input().split()))] for i in range(3)]
N = int(input())
B = []
for _ in range(N):
	b = int(input())
	for r in A:
		for i in range(len(r)):
			if r[i] == b:
				r[i] = 0
ans = False
for i in range(3):
	if sum(A[i]) == 0:
		ans = True
if not ans:
	for i in range(3):
		if A[i][0] + A[i][1] + A[i][2] == 0:
			ans = True
if not ans:
	if A[0][0] + A[1][1] + A[2][2] == 0:
		ans = True
	elif A[0][2] + A[1][1] + A[2][0] == 0:
		ans = True
if ans:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
A = [[j for j in list(map(int, input().split()))] for i in range(3)]
N = int(input())
B = []
for i in range(N):
	B.append(int(input()))
for b in B:
	for r in A:
		for i in range(len(r)):
			if r[i] == b:
				r[i] = 0
ans = False
for i in range(3):
	if sum(A[i]) == 0:
		ans = True
if not ans:
	for i in range(3):
		if A[i][0] + A[i][1] + A[i][2] == 0:
			ans = True
if not ans:
	if A[0][0] + A[1][1] + A[2][2] == 0:
		ans = True
	elif A[0][2] + A[1][1] + A[0][2] == 0:
		ans = True
if ans:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
def bingo(appear):
	for j in range(3):
		if appear[0][j] and appear[1][0] and appear[2][0]:
			return "Yes"
	for i in range(3):
		if appear[i][0] and appear[i][1] and appear[i][2]:
			return "Yes"
	if appear[0][0] and appear[1][1] and appear[2][2]:
		return "Yes"
	if appear[0][2] and appear[1][1] and appear[2][0]:
		return "Yes"
	return "No"


card = []
for _ in range(3):
	arr = list(map(int, input().split()))
	card.append(arr)
appear = [[False for _ in range(3)] for _ in range(3)]
n = int(input())
for _ in range(n):
	a = int(input())
	for i in range(3):
		for j in range(3):
			if a == card[i][j]:
				appear[i][j] = True

print(bingo(appear))

Submission status: Wrong Answer

Solution code:
def check(card):
	summ = 0
	for i in range(3):
		if sum(card[i]) == 0:
			return True
	for j in range(3):
		for i in range(3):
			summ += card[i][j]
		if summ == 0:
			return True
	summ = 0
	i = 0
	j = 0
	while(i < 3 and j < 3):
		summ += card[i][j]
		i += 1
		j += 1
	if summ == 0:
		return True
	i = 0
	j = 2
	summ = 0
	while(i < 3 and j >=0):
		summ += card[i][j]
		i += 1
		j -= 1
	if summ == 0:
		return True
	return False

def search(card, target):
	for i in range(3):
		for j in range(3):
			if card[i][j] == target:
				card[i][j] = 0
	return card

def bingo(card, nums):
	for i in nums:
		card = search(card, i)
		if check(card):
			return "Yes"
	return "No"


card = []
for _ in range(3):
	arr = list(map(int, input().split()))
	card.append(arr)
n = int(input())
nums = []
for _ in range(n):
	a = int(input())
	nums.append(a)
print(bingo(card, nums))

Submission status: Wrong Answer

Solution code:
def mark(n):
    for i in range(n):
        num = int(input())
        if num in A:
            A[A.index(num)]=0

def tate():
    for i in range(3):
        if A[i]==A[i+2] and A[i]==A[i+6]:
            return 1
    return 0

def yoko():
    for i in range(0,7,3):
        if A[i]==A[i+1] and A[i]==A[i+2]:
            return 1
    return 0

def naname():
    if A[4]==A[0] and A[4]==A[8]:
        return 1
    elif A[4]==A[2] and A[4]==A[6]:
        return 1
    else:
        return 0

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())
mark(n)
if tate()+yoko()+naname()>0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def mark(n):
    for i in range(n):
        num = int(input())
        if num in A:
            A[A.index(num)]=0

def tate():
    for i in range(3):
        if A[i]==A[i+2] and A[i]==A[i+6]:
            return 1
    return 0

def yoko():
    for i in range(0,7,2):
        if A[i]==A[i+1] and A[i]==A[i+2]:
            return 1
    return 0
    
def naname():
    if A[4]==A[0] and A[4]==A[8]:
        return 1
    elif A[4]==A[2] and A[4]==A[6]:
        return 1
    else:
        return 0

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())
mark(n)
if tate()+yoko()+naname()>0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def solve():
    card = []
    num_pos = {}
    for i in range(3):
        row = [int(num) for num in input().split()]
        card.append(row)
        for j,num in enumerate(row):
            num_pos[num] = (i,j)

    N = int(input())
    for i in range(N):
        target = int(input())
        # print(int(input()))
        if target in num_pos:
            pos_i, pos_j = num_pos[target]
            card[pos_i][pos_j] = 0

    ans = False
    for row in card:
        if not any(row):
            ans = True
    for column in range(3):
        column_flag = True
        for i in range(3):
            if card[i][column]:
                column_flag = False
        if column_flag:
            ans = True
    for i in range(3):
        diagonal_flag = True
        if card[i][i]:
            diagonal_flag = False
        if diagonal_flag:
            ans = True
    for i in range(3):
        diagonal_flag = True
        if card[2-i][i]:
            diagonal_flag = False
        if diagonal_flag:
            ans = True
    if ans:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def solve():
    card = []
    num_pos = {}
    for i in range(3):
        row = [int(num) for num in input().split()]
        card.append(row)
        for j,num in enumerate(row):
            num_pos[num] = (i,j)

    N = int(input())
    for i in range(N):
        target = int(input())
        # print(int(input()))
        if target in num_pos:
            pos_i, pos_j = num_pos[target]
            card[pos_i][pos_j] = 0

    ans = False
    for row in card:
        if not any(row):
            ans = True
    for column in range(3):
        column_flag = True
        for i in range(3):
            if card[i][column]:
                column_flag = False
        if column_flag:
            ans = True
    for i in range(3):
        diagonal_flag = True
        if card[i][i]:
            diagonal_flag = False
        if diagonal_flag:
            ans = True
    for i in range(3):
        diagonal_flag = True
        if card[2-i][i]:
            diagonal_flag = False
        if diagonal_flag:
            ans = True
    if ans:
        print("Yes")
    else:
        print("No")

    print(card)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

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

#ヨコ
for i in range(3):
    if A[i] == [-1,-1,-1]:
        print("Yes")
        exit()
#タテ
for i in range(3):
    if [A[i][0],A[i][1],A[i][2]] == [-1,-1,-1]:
        print("Yes")
        exit()
#ナナメ
if [A[0][0],A[1][1],A[2][2]] == [-1,-1,-1]:
    print("Yes")
    exit()
if [A[0][2],A[1][1],A[2][0]] == [-1,-1,-1]:
    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 b:
    for k1, v1 in enumerate(A):
        for k2, v2 in enumerate(v1):
            if i == v2:
                A[k1][k2] = 0

for i in range(3):
    if sum(A[i]) == 0:
        print('Yes')
        exit()
    if sum(A[:][i]) == 0:
        print('Yes')
        exit()

if A[0][0] + A[1][1] + A[2][2] == 0:
    print('Yes')
    exit()

if A[0][2] + A[1][1] + A[2][0] == 0:
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:


def checkBingo(A,c):
    for i in range(3):
        for j in range(3):
            if A[i][j]==c:
                A[i][j]=0

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

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

# print(A, min(A[0]),min(A[1]),min(A[2]))
n = int(input())

for i in range(n):
    b = (int(input()))
    # print(A)
    res = checkBingo(A,b)
    if res :
        break

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

Submission status: Wrong Answer

Solution code:


def checkBingo(A,c):
    for i in range(3):
        for j in range(3):
            if A[i][j]==c:
                A[i][j]=0

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

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

# print(A, min(A[0]),min(A[1]),min(A[2]))
n = int(input())

for i in range(n):
    b = (int(input()))
    # print(A)
    res = checkBingo(A,b)
    if res :
        break

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

Submission status: Wrong Answer

Solution code:


def checkBingo(A,c):
    for i in range(3):
        for j in range(3):
            if A[i][j]==c:
                A[i][j]=0

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

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

# print(A, min(A[0]),min(A[1]),min(A[2]))
n = int(input())

for i in range(n):
    b = (int(input()))
    # print(A)
    res = checkBingo(A,b)

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

Submission status: Wrong Answer

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

N = int(input())
for _ 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

ans = "No"
for i in range(3):
  if A[i] == [-1] * 3 or A[:][i] == [-1] * 3:
    ans = "Yes"

if [A[0][0], A[1][1], A[2][2]] == [-1] * 3 or [A[0][2], A[1][1], A[2], 0] == [-1] * 3:
  ans = "Yes"

print(ans)