Problem:


Score : 200 points

Problem Statement

We have a bingo card with a 3\times3 grid. The square at the i-th row from the top and the j-th column from the left contains the number A_{i, j}.

The MC will choose N numbers, b_1, b_2, \cdots, b_N. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints

All values in input are integers.

1 \leq A_{i, j} \leq 100

A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

A_{1, 1} A_{1, 2} A_{1, 3}
A_{2, 1} A_{2, 2} A_{2, 3}
A_{3, 1} A_{3, 2} A_{3, 3}
N
b_1
\vdots
b_N

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.



Sample input:
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
num_count = int(input())
number_list = [0] * num_count
for i in range(num_count):
    number_list[i] = int(input())

bingo_map = [[a, b, c], [d, e, f], [g, h, i]]
bingo_answer = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def bingo(bingo_map, number_list):
    for number in number_list:
        for i, bingo_row in enumerate(bingo_map):
            if number in bingo_row:
                for j, bingo_number in enumerate(bingo_row):
                    if bingo_number == number:
                        bingo_answer[i][j] = 1


def check_bingo():
    return (all(bingo_answer[0]) or all(bingo_answer[1]) or all(bingo_answer[2]) or
    all([bingo_answer[0][0], bingo_answer[1][0], bingo_answer[2][0]]) or
    all([bingo_answer[0][1], bingo_answer[1][1], bingo_answer[2][1]]) or
    all([bingo_answer[0][2], bingo_answer[1][2], bingo_answer[2][2]]) or
    all([bingo_answer[0][0], bingo_answer[1][1], bingo_answer[2][2]]) or
    all([bingo_answer[2][0], bingo_answer[1][1], bingo_answer[0][2]]))

bingo(bingo_map, number_list)

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

Submission status: Wrong Answer

Solution code:
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[0]*3]*3
    for i in range(3): #aを順番に見ていく
        for j in range(3):
            if a[i][j] in b:
                card[i][j] =1
    for i in range(3): # card
        if i == 0:
            if card[i][i] == card[i][i+1] == card[i][i+2]==1:#縦の探索
                print("Yes")
                break
            elif card[i][i] == card[i+1][i] == card[i+2][i]==1:#横の探索
                print("Yes")
                break
            elif card[i][i] == card[i+1][i+1] == card[i+2][i+2]==1:#0の時の斜め            
                print("Yes")
                break
        elif i == 1:
            if card[i-1][i] == card[i][i] == card[i+1][i]==1:
                print("Yes")
                break
            if card[i][0] == card[i][1] == card[i][2]==1:
                print("Yes")
                break
        elif i == 2:
            if card[i-2][i] == card[i-1][i-1] == card[i][i-2] == 1:#2のときの斜
                print("Yes") 
                break
            if card[i-2][i] == card[i-1][i] == card[i][i] == 1:
                print("Yes")
                break
            if card[i][0] == card[i][1] == card[i][2] == 1:
                print("Yes")
                break   
    else:print("No")

if __name__ == "__main__":
    main()

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=1,1
    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:
l=[[]]*3
for k in range(3):
  l[k]=list(map(int,input().split()))
n=int(input())
ll=[[0,0,0]]*3
for k in range(n):
  i=int(input())
  for j in range(3):
    if i in l[j]:
      ll[j][l[j].index(i)]=1
a=0
if ll[0][0]==1:
  if ll[0][1]==1 and ll[0][2]==1:
    a=1
  if ll[1][1]==1 and ll[2][2]==1:
    a=1
  if ll[1][0]==1 and ll[2][0]==1:
    a=1
if ll[0][1]==1 and ll[1][1]==1 and ll[2][1]==1:
  a=1
if ll[0][2]==1:
  if ll[1][1]==1 and ll[2][0]==1:
    a=1
  if ll[1][2]==1 and ll[2][2]==1:
    a=1
if ll[1][0]==1:
  if ll[1][1]==1 and ll[1][2]==1:
    a=1
if ll[2][0]==1:
  if ll[2][1]==1 and ll[2][2]==1:
    a=1
if a==0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
N = []
for i in range(3):
  N1 = list(map(int, input().split(' ')))
  N.append(N1)

N = np.array(N)

M = int(input())

for i in range(M):
  a = int(input())
  
  for j in range(3):
    for k in range(3):
      if N[j, k] == a:
        N[j, k] = 0


  if (np.all(N == 0, axis = 0).any(0)) or (np.all(N == 0, axis = 1).any(0)) or (np.all(np.diag(N) == 0)) or (np.all(np.diag(N) == 0)):
  #if (N[0, :].all() == 0) or (N[1, :].all() == 0) or  (N[2, :].all() == 0) or  (N[:, 0].all() == 0) or (N[:, 1].all() == 0) or (N[:, 2].all() == 0) or (np.diag(N).all() == 0) or (np.diag(np.transpose(N)).all() == 0):
    print('Yes')
    break
  else:
    if i != M-1:
      continue
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
l=[list(map(int,input().split())) for i in range(3)]
n=int(input())
s=set()
for i in range(n):
    s.add(int(input()))
ans="No"
for i in range(3):
    if l[i][0] in s and l[i][1] in s and l[i][2] in s:
        ans="Yes"
    if l[0][i] in s and l[1][i] in s and l[2][i] in s:
        ans="Yes"
    if l[i][i] in s and l[i][i] in s and l[i][i] in s:
        ans="Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
a =[]
for i in range(3):
    a.append(input().split())
#print(a)
n = int(input())



for k in range(n):
    b = input()
    for i in range(3):
      for j in range(3):
        if(b in a[i][j]):
          a[i][j] = 'maru'
          #print('OK')
      

frag = False

for k in range(3):
    i = 0
    #縦
    if((a[i][k] == 'maru') and (a[i+1][k] == 'maru')and(a[i+2][k] == 'maru')):
        frag = True


for k in range(3):
    j = 0
    #横
    if((a[k][j] == 'maru') and (a[k][j+1] == 'maru')and(a[k][j+2] == 'maru')):
        frag = True


#斜め
if((a[0][0] == 'maru')and(a[1][1] == 'maru')and(a[2][2]=='maru')):
    frag = True
if((a[2][0] == 'maru')and(a[1][1] == 'maru')and(a[0][2]=='maru')):
    frag = True
        

if(frag == True):
    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 = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))
loopflag = False
if N >= 3:
    for i in range(len(result)):
        for j in range(len(result)):
            for k in range(len(result)):
                if (i==j or j==k or k==i):
                    break 
                if((result[i] % 3 == result[j] % 3 == result[k] % 3 ) or (result[i] // 3 == result[j] // 3 == result[k] // 3) or (result[i] == 0 and result[j] == 4 and result[k] ==8 ) or (result[i] == 2 and result[j]  == 4 and result[k] == 6 )):
                    loopflag = True
    if loopflag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
a, b, c = (input("Enter 1 ")).split()
e,f, g = (input("Enter 2")).split()
h,i,j = (input("Enter 3")).split()
x = (input("Enter: "))
if (x==a or x==b or x==c or x==e or x==f or x==g or x==h or x==i or x==j):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

X = [
    set([A[0]]),
    set([A[1]]),
    set([A[2]]),
    set([A[0][0], A[1][0], A[2][0]]),
    set([A[0][1], A[1][1], A[2][1]]),
    set([A[0][2], A[1][2], A[2][2]]),
    set([A[0][0], A[1][1], A[2][2]]),
    set([A[0][2], A[1][1], A[2][0]]),
]

for x in X:
    if x <= B:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
bingo = list(map(int, input().split()))
bingo.extend(list(map(int, input().split())))
bingo.extend(list(map(int, input().split())))

N = int(input())

res = "No"

for _ in range(N):
  num = int(input())

  for (index, value) in enumerate(bingo):
    if value == num:
      bingo[index] = 0


## 斜め判定
if bingo[0] == bingo[4] == bingo[8] == 0 or bingo[2] == bingo[4] == bingo[7] == 0:
  res = "Yes"

else:
  ## 縦横判定
  for i in range(3):
    if (bingo[i] == bingo[i+3] == bingo[i+6] == 0 or bingo[3 * i] == bingo[3 * i + 1] == bingo[3 * i + 2] == 0):
      res = "Yes"
      break
  
print(res)

Submission status: Wrong Answer

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

n = int(input())
S = {int(input()) for x in range(n)}

def f(x,y,z):
    return x in S and y in S and z in S

print('Yes' if f(a,b,c) or f(d,e,f) or f(g,h,i) or f(a,d,g) or f(b,e,h) or f(c,f,i) or f(a,e,i) or f(g,e,c) else 'No')

Submission status: Wrong Answer

Solution code:
bingo = []

for i in range(3):
    bingo.append(input().split())

n = int(input())

flat = [flatten for inner in bingo for flatten in inner]

for i in range(n):
    a = input()
    if a in flat:
        flat[flat.index(a)] = "0"

for i in range(3):
    bingo[i] = flat[:3]
    del flat[:3]

count = 0
for i in range(3):
    if bingo.count("0") == 3:
        count += 1
    elif bingo[0][i] + bingo[1][i] + bingo[2][i] == "000":
        count += 1
    elif bingo[0][0] + bingo[1][1] + bingo[2][2] == "000":
        count += 1
    elif bingo[-1][0] + bingo[-2][1] + bingo[-3][2] == "000":
        count += 1

print("Yes" if count > 0 else "No")

Submission status: Wrong Answer

Solution code:
def main():
    A = []
    A.append(list(map(int, input().split(' '))))
    A.append(list(map(int, input().split(' '))))
    A.append(list(map(int, input().split(' '))))

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

    Af = []
    for i in range(3):
        for j in range(3):
            if A[i][j] in b:
                A[i][j] = 0
            Af.append(A[i][j])
    
    bingo_list = [
        [0,1,2],[3,4,5],[6,7,8],
        [0,3,6],[1,4,7],[2,5,8],
        [0,4,8],[2,4,6]
    ]

    ans = False
    for bingo in bingo_list:
        _sum = 0
        for i in bingo:
            _sum += Af[i]
            if _sum == 0:
                ans = True
    
    if ans:
        print("Yes")
    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 = []

for i in range(n):
  b.append(int(input()))


for i in range(len(b)):
  for a_i in range(len(A[0])):
    for a_j in range(len(A[1])):
      if A[a_i][a_j] == b[i]:
        A[a_i][a_j] = 0

ok = 0

# print(all([i == 0 for i in A[0]]))

for j in range(3):
  if all([i == 0 for i in A[j]]):
    ok += 1

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

for i in range(3):
  if A[i][i] != 0:
    break
  if i == 2:
    ok += 1

if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
  ok += 1

if ok > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = list()
A.extend(A1)
A.extend(A2)
A.extend(A3)
N = int(input())
B = list()
result = list()
for _ in range(N):
    B.append(int(input()))
for e in B:
    if e in A:
        result.append(A.index(e))
print(result)
loopflag = False
if N >= 3:
    for i in range(len(result)):
        for j in range(len(result)):
            for k in range(len(result)):
                if (i==j or j==k or k==i):
                    break 
                if((result[i] % 3 == result[j] % 3 == result[k] % 3 ) or (result[i] // 3 == result[j] // 3 == result[k] // 3) or (result[i] == 0 and result[j] == 4 and result[k] ==8 ) or (result[i] == 2 and result[j]  == 4 and result[k] == 6 )):
                    loopflag = True
    if loopflag:
        print('Yes')
    else:
        print('No')
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):
    #print(set(A[i][:]))
    if set(A[i][:]) <= set(B):
        print('Yes')
        ans = 1
        break
    
    if set(A[:][i]) <= set(B):
        print('Yes')
        ans = 1
        break
        
    if i == 0: 
        if set([A[0][0],A[1][1],A[2][2]]) <= set(B):
            print('Yes')
            ans=1
            break
    
        if set([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:
def common_member(a, b): 
    a_set = set(a) 
    b_set = set(b) 
    if (a_set & b_set): 
        return len(a_set & b_set)
    else: 
        return 0

L = list(map(int,input().split()))
L1 = list(map(int,input().split()))
L2 = list(map(int,input().split()))
LL = L + L1 + L2
N = int(input())
M = []
for i in range(N):
    ML = input()
    M.append(int(ML))

res = common_member(M,LL)
if(res == 0):
    print("No")
elif (res >= (N/2)):
    print("Yes")

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)]

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

if cnt<3:
  print("No")
  exit()
    
judge = "Yes"
if a[4]!=0 and a[2]!=0 and a[6]!=0:
  judge = "No"

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

print(judge)

Submission status: Wrong Answer

Solution code:

# input = int(input())
# page = int(input / 2) + input%2
# print("{}".format(page))
def check(mark):
    # abc, def, ghi, adg, beh, cfi, aei, gec
    if my_index(mark, 'a', -1) > 0 and my_index(mark, 'b', -1) > 0 and my_index(mark, 'c', -1) > 0:
        print('Yes')
        return
    if my_index(mark, 'd', -1) > 0 and  my_index(mark, 'e', -1) > 0 and my_index(mark, 'f', -1) > 0:
        print('Yes')
        return
    if my_index(mark, 'g', -1) > 0 and  my_index(mark, 'h', -1) > 0 and my_index(mark, 'i', -1) > 0:
        print('Yes')
        return
    if my_index(mark, 'a', -1) > 0 and  my_index(mark, 'd', -1) > 0 and my_index(mark, 'g', -1) > 0:
        print('Yes')
        return
    if my_index(mark, 'b', -1) > 0 and  my_index(mark, 'e', -1) > 0 and my_index(mark, 'h', -1) > 0:
        print('Yes')
        return
    if my_index(mark, 'c', -1) > 0 and  my_index(mark, 'f', -1) > 0 and my_index(mark, 'i', -1) > 0:
        print('Yes')
        return
    if my_index(mark, 'a', -1) > 0 and  my_index(mark, 'e', -1) > 0 and my_index(mark, 'i', -1) > 0:
        print('Yes')
        return
    if my_index(mark, 'g', -1) > 0 and  my_index(mark, 'e', -1) > 0 and my_index(mark, 'c', -1) > 0:
        print('Yes')
        return
    print('No')

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

a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())

N = int(input())

i = 0
mark = list()
a = list()
eee = ""

while i < N:
    n = int(input())
    i = i + 1
    if n == a:
        mark.append("a")
    if n == b:
        mark.append("b")
    if n == c:
        mark.append("c")
    if n == d:
        mark.append("d")
    if n == e:
        mark.append("e")
    if n == f:
        mark.append("f")
    if n == g:
        mark.append("g")
    if n == h:
        mark.append("h")
    if n == i:
        mark.append("i")

check(mark)

Submission status: Wrong Answer

Solution code:
import sys
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())
  
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")
        sys.exit()
  ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
    sys.exit()
  else:
    print("No")
    sys.exit()

Submission status: Wrong Answer

Solution code:
a = [input().split() for l in range(3)]
n=int(input())
b = [int(input()) for i in range(n)]
for i in range(n):
  if a[0][0]==b[i]:
    a[0][0]=0
  if a[0][1]==b[i]:
    a[0][1]=0
  if a[0][2]==b[i]:
    a[0][2]=0  
  if a[1][0]==b[i]:
    a[1][0]=0
  if a[1][1]==b[i]:
    a[1][1]=0
  if a[1][2]==b[i]:
    a[1][2]=0
  if a[2][0]==b[i]:
    a[2][0]=0
  if a[2][1]==b[i]:
    a[2][1]=0
  if a[2][2]==b[i]:
    a[2][2]=0
if a[0][0]+a[0][1]+a[0][2]==0 or a[1][0]+a[1][1]+a[1][2]==0 or a[2][0]+a[2][1]+a[2][2]==0 \
or a[0][0]+a[1][0]+a[2][0]==0 or a[0][1]+a[1][1]+a[2][1]==0 or a[0][2]+a[1][2]+a[2][2]==0 \
or a[0][0]+a[1][1]+a[2][2]==0 or a[0][2]+a[2][0]+a[1][1]==0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
  row = [int(j) for j in input().split()]
  bingo.append(row)

ans = "No"
n = int(input())
for i in range(n):
  lot = int(input())
  for j in range(len(bingo)):
    col = 0
    for k in range(len(bingo[j])):
      if bingo[j][k] == lot:
      	bingo[j][k] = -1
      col += bingo[j][k]
      if col == -3:
        ans = "Yes"
    if sum(bingo[j]) == -3:
  	  ans = "Yes"
if (bingo[0][0] + bingo[1][1] + bingo[2][2]) == -3:
  ans = "Yes"
if (bingo[0][2] + bingo[1][1] + bingo[2][0]) == -3:
  ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

box=[[0]*3]*3

for i in range(3):
    for j in range(3):
        for k in range(n):
            if b[k]==a[i][j]:
                box[i][j]=1
if box[0]==[1,1,1] or box[1]==[1,1,1] or box[2]==[1,1,1]:
    print("Yes")
elif box[0][0]==1 and box[1][0]==1 and box[2][0]==1:
    print("Yes")
elif box[0][1]==1 and box[1][1]==1 and box[2][1]==1:
    print("Yes")
elif box[0][2]==1 and box[1][2]==1 and box[2][2]==1:
    print("Yes")
elif box[0][2]==1 and box[1][1]==1 and box[2][0]==1:
    print("Yes")
elif box[0][0]==1 and box[1][1]==1 and box[2][2]==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
As = [list(map(int, input().split())) for x in range(3)]
N = int(input())
bs = [int(input()) for x in range(N)]
def createBingo():
  result = [[0,0,0] for x in range(3)]
  i = 0
  while True:
    i2 = 0
    while True:
      if bs[i2] in As[i]:
        result[i][As[i].index(bs[i2])] += 1
      i2 += 1
      if i2 == len(bs)-1:
        break
    i += 1
    if i == len(As):
      break
  return result

def solvd(bingo):
  r = 0
  for x in range(2):
    tmp = set([bingo[0][x], bingo[1][x], bingo[2][x]])
    if check(tmp):
      print("Yes")
      return
    else:
      if x == 0:
        tmp = set([bingo[0][0], bingo[1][1], bingo[2][2]])
        if check(tmp):
          print("Yes")
          return
      elif x == 2:
        tmp = set(bingo[0][2] == bingo[1][1] == bingo[2][0])
        if check(tmp):
          print("Yes")
          return
    bingoSet = set(bingo[x])
    if check(bingoSet):
      r += 1

  if r == 3:
    print("Yes")
  else:
    print("No")

def check(s):
  return len(s) == 1 and list(s)[0] != 0

def main():
  Cs = createBingo()
  solvd(Cs)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a=[]
u=input('')
u=u.split(' ')
a.append(u)
u=input('')
u=u.split(' ')
a.append(u)
u=input('')
u=u.split(' ')
a.append(u)
for p in range(3):
    for q in range(3):
        a[p][q]=int(a[p][q])

n=int(input(''))
b=[]
for p in range(n):
    q=int(input())
    b.append(q)

hit=[]
kara=[0,0,0]
for i in range(3):
    hit.append(kara)

def bingo():
    global hit
    h=0
    if h==0:
        for i in range(3):
            if hit[i][0]*hit[i][1]*hit[i][2]==1:
                h=1
    
    if h==0:
        for i in range(3):
            if hit[0][i]*hit[1][i]*hit[2][i]==1:
                h=1

    if h==0:
        if hit[0][0]*hit[1][1]*hit[2][2]==1:
            h=1
    
    if h==0:
        if hit[2][0]*hit[1][1]*hit[0][2]==1:
            h=1

    return h


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

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

Submission status: Wrong Answer

Solution code:
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
b=[int(input()) for i in range(n)]

aa = []
aa.append(a1)
aa.append(a2)
aa.append(a3)

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

if a[0][0] == a[0][1] and a[0][1] == a[0][2] :
  print("Yes")
if a[1][0] == a[1][1] and a[1][1] == a[1][2] :
  print("Yes")
if a[2][0] == a[2][1] and a[2][1] == a[2][2] :
  print("Yes")
elif a[0][0] == a[1][0] and a[1][0] == a[2][0]:
  print("Yes")
elif a[0][1] == a[1][1] and a[1][1] == a[2][1]:
  print("Yes")
elif a[0][2] == a[1][0] and a[1][2] == a[2][2]:
  print("Yes")
elif a[0][0] == a[1][1] and a[1][1] == a[2][2]:
  print("Yes")
elif a[0][2] == a[1][1] and a[1][1] == a[2][0]:
  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 = [int(input()) for _ in range(N)]

for i in range(3):
  for j in range(3):
    if a[i][j] == b:
      a[i][j] = 0
      
ans = 'No'
for i in range(3):
  if sum(a[i]) == 0:
    ans = 'Yes'
    break
  if a[i][0]+a[i][1]+a[i][2] == 0:
    ans = 'Yes'
    break

if a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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


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

def f(ans):
    if yoko(ans) or tate(ans) or naname(ans):
        return True
    else:
        return False

def yoko(ans):
    tmp = []
    for i in ans:
        tmp.append(sum(i))
    if -3 in tmp:
        return True
    else:
        return False

def tate(ans):
    tmp = [0]*3
    for i in range(3):
        for j in range(3):
            tmp[j] += ans[i][j]
    if -3 in tmp:
        return True
    else:
        return False

def naname(ans):
    tmp = [0]*2
    tmp[0] = ans[0][0] + ans[1][1] + ans[2][2]
    tmp[1] = ans[0][2] + ans[1][1] + ans[2][1]
    if -3 in tmp:
        return True
    else:
        return False


if f(ans):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
N = 3

# 2次元配列
A = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    A.append(array)

A_t = [list(x) for x in zip(*A)]
A_n = [[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]
N = int(input())
B=[]
cnt = [0]*3
for i in range(N):
    B.append(int(input()))
    
cnt[0] =0
num = 0
for j in A:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 2 in cnt:
    print("Yes")
    sys.exit(0)
cnt = [0,0,0]
num = 0
for j in A_t:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 2 in cnt:
    print("Yes")
    sys.exit()
cnt = [0,0,0]
num = 0
for j in A_n:
    for i in j:
        if i in B:
            cnt[num] += 1
    num +=1
if 2 in cnt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
row1=list(map(int,input().split()))
row2=list(map(int,input().split()))
row3=list(map(int,input().split()))
num=int(input())
list=[int(input()) for i in range(num)]

for n in list:
  if n in row1:
    row1 = [0 if i == n else i for i in row1]
  elif n in row2:
    row2 = [0 if i == n else i for i in row2]
  elif n in row3:
    row3 = [0 if i == n else i for i in row3]

# 横
if row1.count(0) == 3 or row2.count(0) or row3.count(0):
  print('Yes')

# 縦
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')
elif row1[0]==0 and row2[0]==0 and row3[0]==0:
  print('Yes')

# ななめ
elif row2[1] == 0:
  if row1[0] == 0 and row3[2] == 0:
    print('Yes')
  elif row1[2] == 0 and row3[0] == 0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    bingo = []
    for i in range(3):
        bingo.append(list(map(int, lines.pop(0).split(' '))))
    bingo = sum(bingo, [])
    N = int(lines.pop(0))
    for i in range(N):
        a = int(lines.pop(0))
        if a in bingo:
            b = bingo.index(a)
            bingo[b] = -1
    atari = [
        [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 ax in atari:
        for i in ax:
            if not bingo[i] < 0:
                continue
            print('Yes')
            return
    print('No')


lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(map(int, input().split()))
d=x+y+z
nalist=[]
N=int(input())
for i in range(N):
    na = int(input())
    nalist.append(na)

for i in nalist:
    if i in d:
        counter=d.index(i)
        d[counter]=101

if d[0]and d[1]and d[2]==101 or d[3] and d[4] and d[5]==101 or d[6]and d[7]and d[8]==101 or d[0] and d[3] and d[6]==101 or d[1] and d[4] and d[7]==101 or d[2] and d[5]and d[8]==101 or d[0]and d[4]and d[8]==101 or d[2]and d[4]and d[6]==101:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import re, sys

A = np.zeros((3,3))
for i in range(3):
  row = input()
  nums = re.split(' ', row)
  for j in range(3):
  	A[i, j] = int(nums[j])
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
for i in range(3):
  if len(set(A[i]) & set(b)) == 3 | len(set(A[:,i]) & set(b)) == 3:
    print('Yes')
    sys.exit()
cross1 = [A[0,0] ,A[1,1], A[2,2]]
cross2 = [A[0,2] ,A[1,1], A[2,0]]
if len(set(cross1) & set(b)) == 3 | len(set(cross2) & set(b)) == 3:
  print('Yes')
  sys.exit()
else:
  print('No')

Submission status: Wrong Answer

Solution code:
def haha():    
    A=[]
    for i in range(3):
        A.extend(list(map(int, input().split())))
    N = int(input())
    n=[]
    while N>0:
        inp = int(input())
        if inp in A:
            n.append(inp)
        N-=1

    A = [A[:3],A[3:6],A[6:9], [A[0], A[4], A[8]], [A[2], A[4], A[6]]]

    for ele in A:
        if ele[0] in n and ele[1]in n and ele[2]in n:
            return 'Yes'
            break
    return 'No'

print(haha())

Submission status: Wrong Answer

Solution code:
import numpy as np
A_1 = [int(i) for i in input().split()]
A_2 = [int(i) for i in input().split()]
A_3 = [int(i) for i in input().split()]
A = np.array([A_1, A_2, A_3])
N = int(input())
b = [int(input()) for i in range(N)]
for i in b:
   A = np.where(A==i,0,A) 

if ((A[0][0]==A[1][1]) and (A[1][1] == A[2][2]) and (A[0][0]==0)):
    print('Yes')
elif ((A[2][0]==A[1][1]) and (A[1][1] == A[0][2]) and (A[2][0]==0)):
    print('Yes')
elif A[0,:].all()==0 or A[:,0].all()==0:
    print('Yes')
elif A[1,:].all()==0 or A[:,1].all()==0:
    print('Yes')
elif A[2,:].all()==0 or A[:,2].all()==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

N = int(input())
number = []

for j in range(N):
    number.append(int(input()))

result = []
for n in range(N):
    for t in range(3):
        for y in range(3):
            if(bingo[t][y] == number[n]):
                result.append([t,y])

bingo_a = 'No'
for r in range(len(result)):
    for t in range(3):
        flag = True
        for y in range(3):
            if(result[r][0] != t or result[r][1] != y):
                flag = False
        if(flag == True):
            bingo_a = 'Yes'

for r in range(len(result)):
    for y in range(3):
        flag = True
        for t in range(3):
            if(result[r][0] != t or result[r][1] != y):
                flag = False
        if(flag == True):   
            bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 0):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 2):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 2):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 0):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

print(bingo_a)