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:
A1 = [0] * 3
A2 = [0] * 3
A3 = [0] * 3
for i in range(3):
    A1[i], A2[i], A3[i] = map(int, input().split())

N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 'ok'
        elif A2[j] == i:
            A2[j] = 'ok'
        elif A3[j] == i:
            A3[j] = 'ok'

for j in range(3):
    if j == 0:
        if A1[j] == A1[j+1] == A1[j+2]:
            print('Yes')
            break
        elif A2[j] == A2[j+1] == A2[j+2]:
            print('Yes')
            break
        elif A3[j] == A3[j+1] == A3[j+2]:
            print('Yes')
            break
        elif A1[j] == A2[j+1] == A3[j+2]:
            print('Yes')
            break
        elif A3[j] == A2[j+1] == A1[j+2]:
            print('Yes')
            break
        elif A1[j] == A2[j] == A3[j]:
            print('Yes')
            break
    elif A1[j] == A2[j] == A3[j]:
        print('Yes')
        break
    else:
        print('No')
        break

Submission status: Wrong Answer

Solution code:
a=[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 int(a[i][j]) in b:
            a[i][j]=999
#印をつける
c=0
for i in range(3):
    if a[i][0]==999 and a[i][1]==999 and a[i][2]==999:
        c+=1
        break
    elif a[0][i]==999 and a[1][i]==999 and a[2][i]==999:
        c+=10
        break
    elif a[0][0]==999 and a[1][1]==999 and a[2][2]==999:
        c+=100
        break
    elif a[0][2]==999 and a[2][2]==999 and a[2][0]==999:
        c+=1000
        break
#print(a)        
if c==0:
    print('No')
else:
    print('Yes')
#print(c)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

f = sys.stdin
A = [list(map(int, f.readline().split(' '))) for _ in range(3)]

f_A = A[0] + A[1] + A[2]

N = int(f.readline())
b = [int(f.readline()) for _ in range(N)]

row = {'0': 0, '1': 0, '2': 0}
col = {'0': 0, '1': 0, '2': 0}
left_diag = 0
right_diag = 0

result = 'No'
for i in range(N):
    idx = -1
    if b[i] in f_A:
        idx = f_A.index(b[i])
    else:
        continue
    i, j = idx // 3, idx % 3
    row[str(i)] += 1
    col[str(j)] += 1
    if i == j:
        left_diag += 1
    if i + j == 3:
        right_diag += 1
    if (row[str(i)] == 3 or col[str(j)] == 3 or left_diag == 3 or right_diag ==
            3):
        result = 'Yes'
        break
# print(row)
# print(col)
# print(left_diag, right_diag)
print(result)

Submission status: Wrong Answer

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

def main():
    import numpy as np
    A = [list(map(int,readline().split())) for _ in range(3)]
    N, *b = map(int, read().split())
    A = np.array(A)
    B = np.zeros(A.shape)
    for i in A.reshape(-1):
        if i in b:
            print(np.where(A == i))
            B[np.where(A == i)] = 1
    for i in range(3):
        if np.all(B[i, :] == 1):
            print('Yes')
            break
        if np.all(B[:, i] == 1):
            print('Yes')
            break
    else:
        if B[0,0]==B[1,1]==B[2,2]==1:
            print('Yes')
        elif B[0,2]==B[1,1]==B[2,0]==1:
            print('Yes')
        else:
            print('No')
    print(B)
    return
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

N = int(input())
import sys
if N < 3:
    print("No")
    sys.exist()

import numpy as np
table = np.zeros(shape=(3,3), dtype="int16")

for _ in range(N):
    b = int(input())
    if b == A11:
        table[0][0] = 1
    elif b == A12:
        table[0][1] = 1
    elif b == A13:
        table[0][2] = 1
    elif b == A21:
        table[1][0] = 1
    elif b == A22:
        table[1][1] = 1
    elif b == A23:
        table[1][2] = 1
    elif b == A31:
        table[2][0] = 1
    elif b == A32:
        table[2][1] = 1
    elif b == A33:
        table[2][2] = 1
        
        
if sum(table[0][:]) == 3 or sum(table[1][:]) == 3 or sum(table[2][:]) == 3 or sum(table[:][0]) == 3 or sum(table[:][1]) == 3 or sum(table[:][2]) == 3 or (table[0][0] + table[1][1] + table[2][2]) == 3 or (table[2][0]+table[1][1] + table[0][2]) == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

m = []

for i in range(0, 3):
    m.append([int(n) for n in input().strip().split(" ")])

ns = []
n = int(input().strip())

for i in range(0, n):
    ns.append(int(input().strip()))

for n in ns:
    for i in range(0, 3):
        for j in range(0, 3):
            if m[i][j] == n:
                m[i][j] = 0

import sys

for i in range(0, 3):
    if sum(m[i]) == 0:
        print('Yes')
        sys.exit(0)

for i in range(0, 3):
    if sum([m[i][0], m[i][1], m[i][2]])  == 0:
        print('Yes')
        sys.exit(0)


if sum([m[0][0], m[1][1], m[2][2]]) == 0 or sum([m[0][2], m[1][1], m[2][0]]) == 0:
    print('Yes')
    sys.exit(0)

print('No')

Submission status: Wrong Answer

Solution code:
import sys

card = []
for i in range(3):
    card.append([int(x) for x in input().split()])

N = int(input())
numbers = set()
for i in range(N):
    numbers.add(int(input()))


def checker(s):
    if len(s) == 1 and 'x' in s:
        print('Yes')
        sys.exit()


for i in range(3):
    for j in range(3):
        if card[i][j] in numbers:
            card[i][j] = 'x'

# checks to see if the rows
for row in card:
    s = set()
    for col in row:
        s.add(col)
    checker(s)

# checks to see if the columns
for i in range(3):
    for j in range(3):
        s = set()
        s.add(card[j][i])
        checker(s)
# diagonals
s = set()
for i in range(3):
    s.add(card[i][i])
checker(s)
a = set()

for i in range(2, -1, -1):
    a.add(card[i][i])
checker(a)

print('No')

Submission status: Wrong Answer

Solution code:
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]
a3 = [int(x) for x in input().split()]
n = int(input())
b = []
for _ in range(n):
    b.append(input())
res = 0
for x in b:
    if int(x) in a1 or int(x) in a2 or int(x) in a3:
        res+=1
if res>=3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

c = [[-1,-1,-1],[-1,-1,-1],[-1,-1,-1]]

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

ans = False

if c[0][0] == 1 & c[0][1] == 1 & c[0][2] == 1:
    ans = True
if c[1][0] == 1 & c[1][1] == 1 & c[1][2] == 1:
    ans = True
if c[2][0] == 1 & c[2][1] == 1 & c[2][2] == 1:
    ans = True
if c[0][0] == 1 & c[1][0] == 1 & c[2][0] == 1:
    ans = True
if c[0][1] == 1 & c[1][1] == 1 & c[2][1] == 1:
    ans = True
if c[0][2] == 1 & c[1][2] == 1 & c[2][2] == 1:
    ans = True
if c[0][0] == 1 & c[1][1] == 1 & c[2][2] == 1:
    ans = True
if c[2][0] == 1 & c[1][1] == 1 & c[0][2] == 1:
    ans = True

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

Submission status: Wrong Answer

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

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

    
judge = "Yes"
if a[4]!=0 and a[2]!=0 and a[6]!=0:
  judge = "No"

if a[4]!=0 and a[0]!=0 and a[8]!=0:
  judge = "No"

print(judge)

Submission status: Wrong Answer

Solution code:
arr=[]
for i in range(3):
    a=list(map(int,input().split()))
    arr.append(a)
n=int(input())
f=0
lst=[]
for i in range(n):
    a=int(input())
    lst.append(a)
if(arr[0][0] in lst and arr[1][1] in lst and arr[2][2] in lst):
    print("Yes")
elif(arr[0][2] in lst and arr[1][1] in lst and arr[2][0] in lst):
    print("Yes")
else:
    for i in range(3):
        f=0
        for j in range(3):
            if(arr[i][j] not in lst):
                f=1
        if(f==0):
            print("Yes")
            break
if(f==1):
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
f = np.zeros((3, 3))
b = np.zeros((3, 3))
f[0]=list(map(int,input().split()))
f[1]=list(map(int,input().split()))
f[2]=list(map(int,input().split()))
n= int(input())
for i in range(n):
  c = int(input())
  b=np.where(f == c, b + 1, b)
  #print(b)
b=np.where(b > 0, 1, 0)
#print(b)
if all(b[0][:])|all(b[1][:])|all(b[2][:])\
|all(b[:][0])|all(b[:][1])|all(b[:][2])\
|all((b[0][0],b[1][1],b[2][2]))|all((b[0][2],b[1][1],b[2][0])):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a1 = input().split()
a2 = input().split()
a3 = input().split()

n = int(input())

bingo_sheet = a1 + a2 + a3

atari = []


for _ in range(n):
    num = input()
    try:
        atari_index = bingo_sheet.index(num)
        atari.append(str(atari_index + 1))
    except:
        continue


atari_true = False

if '1' in atari:
    if '2' in atari:
        if '3' in atari:
            atari_true = True
    if '4' in atari:
        if '7' in atari:
            atari_true = True
    if '5' in atari:
        if '9' in atari:
            atari_true = True

if '2' in atari:
    if '5' in atari:
        if '8' in atari:
            atari_true = True

if '3' in atari:
    if '6' in atari:
        if '9' in atari:
            atari_true = True

if '4' in atari:
    if '5' in atari:
        if '6' in atari:
            atari_true = True

if '3' in atari:
    if '6' in atari:
        if '9' in atari:
            atari_true = True
    if '5' in atari:
        if '7' in atari:
            atari_true = True

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

Submission status: Wrong Answer

Solution code:
a = []
for i in range(3):
    ai = list(map(int, input().split()))
    a += [ai]
bingo = [[False, False, False], [False, False, False], [False, False, False]]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            bingo[j][a[j].index(b)] = True
            break
e = []
d = []
c = []
r = []
l = []
count = 0
for i in range(3):
    if not (False in bingo[j]):
        print("Yes")
        exit()
    e.append(bingo[i][0])
    d.append(bingo[i][1])
    c.append(bingo[i][2])
    r.append(bingo[i][count])
    l.append(bingo[i][2 - count])
    count += 1
if not (False in e):
    print("Yes")
    exit()
elif not (False in d):
    print("Yes")
    exit()
elif not (False in c):
    print("Yes")
    exit()
elif not (False in r):
    print("Yes")
    exit()
elif not (False in l):
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
def get_key(val):
    for key, value in dict.items():
        if val == value:
            return key


A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
dict = {}
lst = []
N = int(input())
for i in range(0, N):
    lst.append(int(input()))
for j in lst:
    if j in A:
        dict[A.index(j)] = "A"
    if j in B:
        dict[B.index(j)] = "B"
    if j in C:
        dict[C.index(j)] = "C"

if (get_key("A") == 0 and get_key("B") == 1 and get_key("C") == 2) or (
        get_key("A") == 1 and get_key("B") == 1 and get_key("C") == 1) or (
        get_key("A") == 0 and get_key("B") == 0 and get_key("C") == 0) or (
        get_key("A") == 2 and get_key("B") == 2 and get_key("C") == 2) or (
        get_key("A") == 0 and get_key("A") == 1 and get_key("A") == 2) or (
        get_key("B") == 0 and get_key("B") == 1 and get_key("B") == 2) or (
        get_key("C") == 0 and get_key("C") == 1 and get_key("C") == 2) or (
(get_key("A") == 2 and get_key("B") == 1 and get_key("C") == 0)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
array = []
for i in range(3):
  alist = list(map(int, input().split()))
  array.append(alist)
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))

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

flg = False
for i in range(3):
  if sum(array[i]) == 0:
    flg = True
for i in range(3):
  if (array[i][0] + array[i][1] + array[i][2]) == 0:
    flg = True
if (array[0][0] + array[1][1] + array[2][2]) == 0:
  flg = True
if (array[2][0] + array[1][1] + array[0][2]) == 0:
  flg = True
  
if flg:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
A1 = [0] * 3
A2 = [0] * 3
A3 = [0] * 3
for i in range(3):
    A1[i], A2[i], A3[i] = map(int, input().split())

N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

for i in b:
    for j in range(3):
        if A1[j] == i:
            A1[j] = 'ok'
        elif A2[j] == i:
            A2[j] = 'ok'
        elif A3[j] == i:
            A3[j] = 'ok'

for j in range(3):
    if j == 0:
        if A1[j] == A1[j+1] == A1[j+2]:
            print('Yes')
            break
        elif A2[j] == A2[j+1] == A2[j+2]:
            print('Yes')
            break
        elif A3[j] == A3[j+1] == A3[j+2]:
            print('Yes')
            break
        elif A1[j] == A2[j+1] == A3[j+2]:
            print('Yes')
            break
        elif A3[j] == A2[j+1] == A1[j+2]:
            print('Yes')
            break
    elif A1[j] == A2[j] == A3[j]:
        print('Yes')
        break
    else:
        print('No')
        break

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)]
l=[]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i]==a[j][k]:
        l.append([j+1,k+1])
if len(l)>=7:
  print('Yes')
elif len(l)<=2:
  print('No')
else:
  if l.count([1,1])==l.count([2,2])==l.count([3,3])==1 or l.count([1,3])==l.count([2,2])==l.count([3,1])==1:
    print('Yes')
  else:
    count1,count2=0,0
    for i in range(len(l)-1):
      if l[i][0]==l[i+1][0]:
        count1+=1
      if l[i][1]==l[i+1][1]:
        count2+=1
    if count1==3 or count2==3:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A1 = list(map(int,input().split(' ')))
A2 = list(map(int,input().split(' ')))
A3 = list(map(int,input().split(' ')))
N = int(input())
B = [0]*N
for i in range(N):
    b = int(input())
    B[i]=b

marubatu = [[0,0,0],
[0,0,0],
[0,0,0]]

for b in B:
    for i,a1 in enumerate(A1):
        if b==a1:
            marubatu[0][i]=1
    for i,a2 in enumerate(A2):
        if b==a2:
            marubatu[1][i]=1
    for i,a3 in enumerate(A3):
        if b==a3:
            marubatu[2][i]=1

def tate():
    f = False
    for i in range(3):
        if (marubatu[i][0])and(marubatu[i][1])and(marubatu[i][2]==1):
            f=True
    return f

def yoko():
    f = False
    for i in range(3):
        if (marubatu[0][i])and(marubatu[1][i])and(marubatu[2][i]==1):
            fl=True
    return f

def migisagari():
    f = False
    if (marubatu[0][0])and(marubatu[1][1])and(marubatu[2][2]==1):
        f=True
    return f

def hidarisagari():
    flag=False
    if (marubatu[0][2])and(marubatu[1][1])and(marubatu[2][0]==1):
        flag=True
    return flag

#print(marubatu)

f1 = tate()
f2 = yoko()
f3 = migisagari()
f4 = hidarisagari()

if f1 or f2 or f3 or f4:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A_1 = list(map(int, input().split()))
A_2 =list(map(int, input().split()))
A_3 =list(map(int, input().split()))
A = A_1 +A_2 +A_3
N = int(input())
b = [int(input()) for _ in range(N)]
for i in range(N):
    for j in range(9):
        if b[i] == A[j]:
            A[j] = 0
if A[0]==A[1]==A[2]==0 or A[3]==A[4]==A[5]==0 or A[6]==A[7]==A[8]==0 or A[0]==A[3]==A[6]==0 or A[1]==A[4]==A[7]==0 or A[2]==A[5]==A[8]==0 or A[0]==A[4]==A[8]==0 or A[2]==A[4]==A[7]==0:          
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

m = []

for i in range(0, 3):
    m.append([int(n) for n in input().strip().split(" ")])

ns = []
n = int(input().strip())

for i in range(0, n):
    ns.append(int(input().strip()))

for n in ns:
    for i in range(0, 3):
        for j in range(0, 3):
            if m[i][j] == n:
                m[i][j] = 0

import sys

for i in range(0, 2):
    if sum(m[i]) == 0:
        print('Yes')
        sys.exit(0)

for i in range(0, 2):
    if sum([m[i][0], m[i][1], m[i][2]])  == 0:
        print('Yes')
        sys.exit(0)


if sum([m[0][0], m[1][1], m[2][2]]) == 0 or sum([m[0][2], m[1][1], m[2][0]]) == 0:
    print('Yes')
    sys.exit(0)

print('No')

Submission status: Wrong Answer

Solution code:
a = [input().split() for l in range(3)]

n=int(input())
b = [(input()) for i in range(n)]
s=[]
for i in range(n):
  for j in range(3):
    if b[i] in a[j]:
      k=a[j].index(b[i])
      s.append([j,k])
      if [j,0] in s and [j,1] in s and [j,2] in s:
        print("YES")
        break
      elif [0,k] in s and [1,k] in s and [2,k] in s:
        print("YES")
        break
      elif j==k:
        if [0,0] in s and [1,1] in s and [2,2] in s:
          print("YES")
          break
        elif [0,2] in s and [1,1] in s and [2,0] in s:
          print("YES")
          break
  else:
    continue
  break
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
A1 = list(map(int,input().rstrip().split()))
A2 = list(map(int,input().rstrip().split()))
A3 = list(map(int,input().rstrip().split()))

a = []
a.append(A1)
a.append(A2)
a.append(A3)

N = int(input().rstrip())
b = []
for i in range(N):
  b.append(int(input().rstrip()))

out = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for t in b:
  for m in range(3):
    for n in range(3):
      if a[m][n] == t :
        out[m][n] = 1

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

Submission status: Wrong Answer

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

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

    
judge = "Yes"
if a[4]!=0 and a[2]!=0 and a[6]!=0:
  judge = "No"

if a[4]!=0 and a[0]!=0 and a[7]!=0:
  judge = "No"

print(judge)

Submission status: Wrong Answer

Solution code:
import sys

card = []
for i in range(3):
    card.append([int(x) for x in input().split()])

N = int(input())
numbers = set()
for i in range(N):
    numbers.add(int(input()))


def checker(s):
    if len(s) == 1 and 'x' in s:
        print('Yes')
        sys.exit()


for i in range(3):
    for j in range(3):
        if card[i][j] in numbers:
            card[i][j] = 'x'

# checks to see if the rows
for row in card:
    s = set()
    for col in row:
        s.add(col)
    checker(s)

# checks to see if the columns
for i in range(3):
    for j in range(3):
        s = set()
        s.add(card[j][i])
        checker(s)
# diagonals
s = set()
for i in range(3):
    s.add(card[i][i])
checker(s)

for i in range(2, -1, -1):
    s.add(card[i][i])
checker(s)

print('No')

Submission status: Wrong Answer

Solution code:
A = list(input().split() for l in range(3))
N = int(input())
B = list(int(input()) for i in range(N))

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

def bingo(A):
    for i in range(3):
        if A[i][0] + A[i][0] + A[i][2] == "000" or A[0][i] + A[1][i] + A[2][i] == "000" or A[0][0] + A[1][1] + A[2][2] == "000" or A[0][2] + A[1][1] + A[2][0] == "000":
            return "Yes"
    return "No"

print(bingo(A))

Submission status: Wrong Answer

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

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

    flag = False
    for i in range(3):
        for j in range(3):
                if(j+2 < 3 and A[i][j] == 0 and A[i][j+1] == 0 and A[i][j+2] == 0):
                    flag = True
                    break
                if(i+2 < 3 and A[i][j] == 0 and A[i+1][j] == 0 and A[i+2][j] == 0):
                    flag = True
                    break
                if(i+2 < 3 and j+2 < 3 and A[i][j] == 0 and A[i+1][j+1] == 0 and A[i+2][j+2] == 0):
                    flag = True
                    break
                if(i-2 >= 0 and j-2 >= 0 and A[i][j] == 0 and A[i-1][j-1] == 0 and A[i-2][j-2] == 0):
                    flag = True
                    break
        if(flag):
            break

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
A = [[0] * 3] * 3

for i in range(3):
    a, b, c = map(int, input().split())
    A[i][0], A[i][1], A[i][2] = a, b, c

N = int(input())
B = [0] * N
for i in range(N):
    B[i] = int(input())

# input ここまで
import itertools
def flatten_list(l):
    return list(itertools.chain.from_iterable(l))

mark_list = [False] * 9

flatten_A = flatten_list(A)
for b in B:
    if not b in flatten_A: continue
    # 選ばれた数が自分のビンゴに含まれている
    for i in range(9):
        if flatten_A[i] == b:
            mark_list[i] = True

"""
[0, 1, 2], [3, 4, 5], [6, 7, 8]
[0, 3, 6], [1, 4, 7], [2, 5, 8]
[0, 4, 8], [2, 4, 6]
"""
def judge_bingo(l):
    yes = "Yes"
    no = "No"
    if l.count(True) < 3:
        return no
    if l[0] == 1:
        if (l[1] and l[2]) or (l[3] and l[6]) or (l[4] and l[8]):
            return yes
    if l[3] and l[4] and l[5]:
        return yes
    if l[1] and l[4] and l[7]:
        return yes
    if l[2]:
        if l[4] and l[6]: return yes
        if l[5] and l[8]: return yes
    if l[6] and l[7] and l[8]:
        return yes
    return no
        

ans = judge_bingo(mark_list)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()
N=int(input())
numbers=[input() for i in range(N)]

number=list(map(int,numbers))
A=int(a)
B=int(b)
C=int(c)
D=int(d)
E=int(e)
F=int(f)
G=int(g)
H=int(h)
I=int(i)

for n in number:
    if A==n:
        A=0
    elif B==n:
        B=0
    elif C==n:
        C=0
    elif D==n:
        D=0
    elif E==n:
        E=0
    elif F==0:
        F=0
    elif G== n:
        G = 0
    elif H == n:
        H = 0
    elif I == n:
        I = 0
    else:
        pass

if A==B==C or D==E==F or G==H==I or A==D==G or B==E==H or C==F==I or A==E==I or C==E==G:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A1 = [int(i) for i in input().split()]
A2 = [int(i) for i in input().split()]
A3 = [int(i) for i in input().split()]
# print(A1)
# print(A2)
# print(A3)

N = int(input())
B = []
for b in range(N):
    B.append(int(input())) 

for b in B:
    if b in A1:
        A1[A1.index(b)] = 0
    elif b in A2:
        A2[A2.index(b)] = 0
    elif b in A3:
        A3[A3.index(b)] = 0

if sum(A1) * sum (A2) * sum(A3) == 0:
    print("Yes")
elif (A1[0]*A2[0]*A3[0]) * (A1[1]*A2[1]*A3[1]) * (A1[2]*A2[2]*A3[2]) * (A1[0]*A2[1]*A3[2]) * (A1[2]*A2[1]*A2[0]) == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

N = int(input())

B = []
for i in range(N):
    B.append(int(input()))

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

ans = "NO"
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        ans = "YES"
        break
    if A[0][i] == A[1][i] == A[2][i] == 0:
        ans = "YES"
        break
    if A[0][0] == A[1][1] == A[2][2] == 0:
        ans = "YES"
        break
    if A[0][2] == A[1][1] == A[2][0] == 0:
        ans = "YES"
print(ans)

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())
l = [int(input()) for i in range(n)]
if (a11 and a12 and a13 in l) or (a21 and a22 and a23 in l) or (a31 and a32 and a33 in l) or (a11 and a21 and a31 in l) or (a12 and a22 and a32 in l) or (a13 and a23 and a33 in l) or (a11 and a22 and a33 in l) or (a31 and a22 and a31 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()) 
B = []
for i in range(n):
    b = int(input())
    B.append(b)
    
ans = 0
for i in range(3):
    if set(A[i][:]) <= set(B):
        print('Yes')
        ans = 1
        break
    
    elif set(A[:][i]) <= set(B):
        print('Yes')
        ans = 1
        break
        
    if i == 0: 
        if set(list((A[0][0],A[1][1],A[2][2]))) <= set(B):
            print('Yes')
            ans=1
            break
    
        elif set(list((A[2][0],A[1][1],A[0][2]))) <= set(B):
            print('Yes')
            ans=1
            break
if ans == 0:
    print('No')

Submission status: Wrong Answer

Solution code:
bingo = [[],[],[]]

for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
if N < 9:
  print("No")
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0

for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
  ANS = 0

for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
  ANS = 0

if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
 

print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np


def main():
    A = np.array([list(map(int, input().split())) for _ in range(3)])
    N = int(input())
    B = np.array([int(input()) for _ in range(N)])
    if N < 3:
        print('No')
        exit(0)

    result = np.zeros((3, 3))

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

    for i in range(3):
        if all(result[i, :]):
            print('Yes')
            exit(0)
    for i in range(3):
        if all(result[:, i]):
            print('Yes')
            exit(0)
    if all([result[0, 0], result[1, 1], result[2, 2]]):
        print('Yes')
        exit(0)
    print('No')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#python3

def main():
    a = []
    for _ in range(3):
        x, y, z = map(int, input().split())
        a.append((x, y, z))
    n = int(input())
    b =[]
    for _ in range(n):
        b.append(int(input()))

    g = [[0 for _ in range(3)] for _ in range(3)]
    for i in range(3):
        for j in range(3):
            flag = False
            for k in range(n):
                if a[i][j] == b[k]:
                    flag = True
            if flag:
                g[i][j] = 1
    

    bingo = False
    for i in range(3):
        flag = True
        if g[i][i] != 1:
            flag = False
        if flag:
            bingo = True            

    for i in range(3):
        flag = True
        if g[2-i][2-i] != 1:
            flag = False  
        if flag:
            bingo = True

    for i in range(3):
        if sum(g[i]) == 3:
            bingo = True

    if (g[0][0] + g[1][0] + g[2][0]):
        bingo = True
    
    if (g[0][1] + g[1][1] + g[2][1]):
        bingo = True
    
    if (g[0][2] + g[1][2] + g[2][2]):
        bingo = True

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

i=0
A = []
while i < 3: 
    m = map(int, input().split())
    A.append(list(m))
    i+=1
#print(A)
n=int(input())

i=0
lst = []
while i < n: 
    b = int(input())
    lst.append(b)
    i+=1
#print(lst)
a= {}
for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in lst:
            a[str(i)+str(j)] = 1
        else:
            a[str(i)+str(j)] = 0


if a["00"] + a["01"]+ a["02"] == 3 \
    or a["10"] + a["11"] + a["12"] == 3 \
    or a["20"] + a["21"] + a["22"] == 3 \
    or a["00"] + a["10"] + a["20"] == 3 \
    or a["01"] + a["11"] + a["21"] == 3 \
    or a["02"] + a["12"] + a["22"] == 3 \
    or a["00"] + a["11"] + a["22"] ==3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

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

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