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_1=84 
A1_2=97
A1_3=66
A2_1=79 
A2_2=89
A2_3=11
A3_1=61
A3_2=59
A3_3=7
B=[89,7,87,79,24,84,30]
N=len(B)
a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    A=[[] for _ in range(3)]
    for i in range(3):
        A[i]=LI()
    N=I()
    for _ in range(N):
        b=I()
        for i in range(3):
            for j in range(3):
                if A[i][j]==b:
                    A[i][j]=0
                    
    f=0
                
    for i in range(3):
        a=0
        for j in range(3):
            a+=A[i][j]
        if a==0:
            f=1
            
    for i in range(3):
        a=0
        for j in range(3):
            a+=A[j][i]
        if a==0:
            f=1
    a=0        
    for i in range(3):
        a+=A[i][i]
        if a==0:
            f=1
            
    a=A[2][0]+A[1][1]+A[0][2]
    if a==0:
        f=1
        
    if f==1:
        print("Yes")
    else:
        print("No")
            
    
        
        
            
        
                
        
    

main()

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        if b in a[j]:
            idx = a[j].index(b)
            a[j][idx] = 0
print(a)
for k in range(3):
    if sum(a[k]) == 0:  # 横の確認
        print('Yes')
        exit()
    elif a[0][k] + a[1][k] + a[2][k] == 0:
        print("Yes")
        exit()
if a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A_list = []

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

for i in range(3):
  a, b, c = map(int, input().split())
  A_list.append(a)
  A_list.append(b)
  A_list.append(c)

N = int(input())
flag=True

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

  tmp = my_index(A_list, num)
  if tmp != False or tmp == 0:
    A_list[tmp] = -1
  
  if ((A_list[0] == A_list[3]) and (A_list[0] == A_list[6]) and (A_list[3] == A_list[6])) or ((A_list[1] == A_list[4]) and (A_list[1] == A_list[7]) and (A_list[4] == A_list[7])) or ((A_list[2] == A_list[5]) and (A_list[2] == A_list[8]) and (A_list[5] == A_list[8])) or ((A_list[0] == A_list[4]) and (A_list[0] == A_list[8]) and (A_list[4] == A_list[8])) or ((A_list[2] == A_list[4]) and (A_list[2] == A_list[6]) and (A_list[4] == A_list[6])):
    print("Yes")
    flag=False
    break

if flag:
  print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(3):
    if A[i] <= B or (A[0][i] in B and A[1][i] in B and A[2][i] in B):
        print('Yes')
        sys.exit()

if (A[0][0] in B and A[1][1] in B
        and A[2][2] in B) or (A[0][2] in B and A[1][1] in B and A[2][0] in B):
    print('Yes')
    sys.exit()

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 = list(int(input()) for i in range(N))

ans = 0
for a in A1:
  if a in B:
    ans += 1
if ans == 3:
  print('Yes')
else:
  ans = 0
  for a in A2:
    if a in B:
      ans += 1
  if ans==3:
    print('Yes')
  else:
    ans = 0
    for a in A3:
      if a in B:
        ans += 1
    if ans==3:
      print('Yes')  
    else:
      ans = 0
      for a in [A1[0], A2[0], A3[0]]:
        if a in B:
          ans += 1
      if ans==3:
        print('Yes') 
      else:
        ans = 0
        for a in [A1[1], A2[1], A3[1]]:
          if a in B:
            ans += 1
        if ans==3:
          print('Yes')
        else:
          ans = 0
          for a in [A1[2], A2[2], A3[2]]:
            if a in B:
              ans += 1
          if ans==3:
            print('Yes')
          else:
            ans = 0
          for a in [A1[0], A2[1], A3[2]]:
            if a in B:
              ans += 1
          if ans==3:
            print('Yes')
          else:
            ans = 0
            for a in [A1[2], A2[1], A3[0]]:
              if a in B:
                ans += 1
            if ans==3:
              print('Yes')
            else:
              print('No')

Submission status: Wrong Answer

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

import sys

DEBUG = False

def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    bingo = [[]] * 3
    bingo[0] = read_int_list()
    bingo[1] = read_int_list()
    bingo[2] = read_int_list()
    locs = {}
    for y in range(0, 3):
        for x in range(0, 3):
            locs[bingo[y][x]] = (y, x)
            
    n = read_int()
    for _ in range(0, n):
        b = read_int()
        if b in locs:
            bingo[locs[b][0]][locs[b][1]] = -1
    
    # column check
    for y in range(0, 3):
        is_bingo = True
        for x in range(0, 3):
            if bingo[y][x] != -1:
                is_bingo = False
                break
        if is_bingo:
            print("Yes")
            return
    # row check
    for x in range(0, 3):
        is_bingo = True
        for y in range(0, 3):
            if bingo[y][x] != -1:
                is_bingo = False
                break
        if is_bingo:
            print("Yes")
            return
    # cross check
    for (x, y), (dx, dy) in ([[0, 0], [2, 2]], [[1, 1], [-1, -1]]):
        is_bingo = True
        while is_bingo and 0 <= y < 3 and 0 <= x < 3:
            if bingo[y][x] != -1:
                is_bingo = False
                break
            y += dy
            x += dx
        if is_bingo:
            print("Yes")
            return
    print("No")
            


        



    pass


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

#print(L)
n = int(input())
li = []
for i in range(n):
    li.append(int(input()))
flag = False
for i in range(3):
    for j in range(3):
        if L[i][j] in li:
            flag = True
    if flag :
        print("Yes")
        exit()
for j in range(3):
    for i in range(3):
        if L[i][j] in li:
            flag = True
    if flag:
        print("Yes")
        exit()
print("NO")

Submission status: Wrong Answer

Solution code:
Aa = [0]*3
for i in range(3):
    Aa[i] = [int(j) for j in  input().split()]
N = int(input())
b = [0] * N
for i in range(N):
    b[i] = int(input())
A = [[False] * 3 for _ in range(3)]
for i in range(N):
    for k in range(3):
        for t in range(3):
            if Aa[k][t] == b[i]:
                A[k][t] = True
for i in range(3):
    if A[i] == [True,True,True]:
        print("Yes")
        exit()
for i in range(3):
    if A[i][0] == True and A[i][1] == True and A[i][2] == True:
        print("Yes")
        exit()
if A[0][0] == True and A[1][1] == True and A[2][2] == True:
    print("Yes")
    exit()
if A[0][2] == True and A[1][1] == True and A[2][0] == True:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:

H = 3
S = [list(map(int, input().split())) for i in range(H)]

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

N = int(input())

for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == S[j][k]:
                list[j][k] += 1


#ななめ
if list[0][0] == 1 and list[1][1] == 1 and list[2][2] == 1:
    print('Yes')
    exit()

# 横
for i in range(3):
    if list[i][0] == 1 and list[i][1] == 1 and list[i][2] == 1:
        print('Yes')
        exit()

# 縦
for i in range(3):
    if list[0][i] == 1 and list[1][i] == 1 and list[2][i] == 1:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
As = []
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))

cs = [[0,0,0], [0,0,0],[0,0,0]]
pos_dic = {}
for i,x in enumerate(As):
  for j,xx in enumerate(x):
    pos_dic[xx] = (i,j)
    
def check(cs):
  for i in range(3):
    if sum(cs[i]) == 3:
      return True
    if (cs[i][0] + cs[i][1] + cs[i][2]) == 3:
      return True
  if (cs[2][2] + cs[1][1] + cs[0][0]) == 3:
    return True
  if (cs[2][0] + cs[1][1] + cs[0][2]) == 3:
    return True
  return False
    

flag = 0
N = int(input())
for i in range(N):
  x = int(input())
  if x in pos_dic:
    i,j = pos_dic[x]
    cs[i][j] = 1
    if check(cs):
      flag = 1
      print("Yes")
      break
if flag == 0:
  print("No")

Submission status: Wrong Answer

Solution code:
def main():
    row1 = list(map(int, input().split()))
    row2 = list(map(int, input().split()))
    row3 = list(map(int, input().split()))
    n = int(input())
    nums = []
    for _ in range(n):
        nums.append(int(input()))

    result = 'No'
    for num in nums:
        for i in range(3):
            if num == row1[i]:
                row1[i] = 0
        for i in range(3):
            if num == row2[i]:
                row2[i] = 0
        for i in range(3):
            if num == row3[i]:
                row3[i] = 0

    if row1.count(0):
        result = 'Yes'
    elif row2.count(0):
        result = 'Yes'
    elif row3.count(0):
        result = 'Yes'
    elif row1[0] == 0 and row2[0] == 0 and row3[0] == 0:
        result = 'Yes'
    elif row1[1] == 0 and row2[1] == 0 and row3[1] == 0:
        result = 'Yes'
    elif row1[2] == 0 and row2[2] == 0 and row3[2] == 0:
        result = 'Yes'
    elif row1[0] == 0 and row2[1] == 0 and row3[2] == 0:
        result = 'Yes'
    elif row1[2] == 0 and row2[1] == 0 and row3[0] == 0:
        result = 'Yes'
    print(result)


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()))
a = [a1,a2,a3]
n = int(input())
b=[]
for i in range(n):
    c = int(input())
    b.append(c)
ref = [[0]*3 for i in range(3)]
for i in b:
    if i in a1:
        j = a1.index(i)
        ref[0][j] = 1
    elif i in a2:
        j = a2.index(i)
        ref[0][j] = 1
    elif i in a3:
        j = a3.index(i)
        ref[0][j] = 1
    else: pass

if sum(ref[0])==3 or sum(ref[1])==3 or sum(ref[2])==3:
    print("Yes")
elif ref[0][0]+ref[1][0]+ref[2][0]==3:
    print("Yes")
elif ref[0][1]+ref[1][1]+ref[2][1]==3:
    print("Yes")
elif ref[0][2]+ref[1][2]+ref[2][2]==3:
    print("Yes")
elif ref[0][0]+ref[1][1]+ref[2][2]==3:
    print("Yes")
elif ref[0][2]+ref[1][1]+ref[2][0]==3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

import numpy as np
A = np.array(A)

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

ans = [[False] * 3 for _ in range(3)]
ans = np.array(ans)

for b in B:
    temp = (A == b)

    ans = np.logical_or(ans, temp)


if ans[0, :].all() or ans[1, :].all() or ans[2, :].all():
    print("Yes")

elif ans[:, 0].all() or ans[:, 1].all() or ans[:, 2].all():
    print("Yes")

elif ans[0, 0] and ans[1, 1] and ans[2, 2]:
    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)]

bingo=[[0]*3 for _ in range(3)]
for i in range(n):
  for ai in range(3):
    for aj in range(3):
      if A[ai][aj]==B[i]:
        bingo[ai][aj]=1
flag=False
for bi in range(3):
  if bingo[bi][0]==bingo[bi][1]==bingo[bi][2]==1: flag=True
  if bingo[0][bi]==bingo[1][bi]==bingo[1][bi]==1: flag=True
if bingo[0][0]==bingo[1][1]==bingo[2][2]==1: flag=True
if bingo[0][2]==bingo[1][1]==bingo[2][0]==1: flag=True    
if flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

r = [False, False, False]
R = [r, r, r]
for b in B:
    for (ai, a) in enumerate(A):
        for (aai, aa) in enumerate(a):
            if aa == b:
                R[ai][aai] = True

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

Submission status: Wrong Answer

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

a_true = [[False for i in range(3)] for j in range(3)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                a_true[j][k] = True
                
bingo = True
                
for i in range(3):
    for j in range(3):
        if a_true[i][j] == False:
            bingo = False
            break
    if bingo == True:
        print('Yes')
        exit()

for i in range(3):
    for j in range(3):
        if a_true[j][i] == False:
            bingo = False
            break
    if bingo == True:
        print('Yes')
        exit()

if a_true[1][1] == True:
    if a_true[0][0] == True:
        if a_true[2][2] == True:
            print('Yes')
            exit()
    elif a_true[0][2] == True:
        if a_true[2][0] == True:
            print('Yes')
            exit()
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

a = []
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
n = int(input())
c = [[0,0,0],[0,0,0],[0,0,0]]

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

flag = False

for i in range(3):
    if c[0][i] + c[1][i] + c[2][i] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    if c[i][0] + c[i][1] + c[i][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    if c[i%3][0] + c[(i+1)%3][1] + c[(i+2)%3][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break

if flag == False:
    print("No")

Submission status: Wrong Answer

Solution code:
card = []
for i in range(3):
  card += list(map(int, input().split()))
N = int(input())
bingo = [(1, 2, 3), (4, 5, 6), (7, 8, 9), (1, 4, 7), (2, 5, 8), (1, 5, 9), (3, 5, 7)]
for i in range(N):
  n = int(input())
  if n in card:
    card[card.index(n)] = "hit"
#print(card)
ans = "No"
for patt in bingo:
  if card[patt[0]-1] == card[patt[1]-1] == card[patt[2]-1] == "hit":
    ans = "Yes"
    break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
#n=int(input())
#l = list(map(int,input().split()))
#a,b,c = map(int,input().split())

ly = []

for i in range(3):
    ly.append(list(map(int,input().split())))

lt = []

for i in range(3):
    l = []
    for j in range(3):
        l.append(ly[j][i])
    lt.append(l)

l = ly+lt + [[ly[0][0],ly[1][1],lt[2][2]]] + [[ly[0][2],ly[1][1],ly[2][0]]]
print(l)

n = int(input())
nm = []
for i in range(n):
    s = int(input())
    nm.append(s)

for i in l:
    t = [0,0,0]
    if i [0] in nm:
        t[0] = 1
    if i [1] in nm:
        t[1] = 1
    if i [2] in nm:
        t[2] = 1
    if sum(t) == 3:
        print("Yes")
        sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
nums = []

for i in range(3):
    nums.append([int(n) for n in input().split(" ")])
print(nums)

bingo_list = []

bingo_list.extend(nums)
for i in range(3):
    bingo_list.append([nums[0][i], nums[1][i], nums[2][i]])
bingo_list.append([nums[0][0], nums[1][1], nums[2][2]])
bingo_list.append([nums[2][0], nums[1][1], nums[0][2]])

print(bingo_list)

is_bingo = False
n = int(input())
for i in range(n):
    num = int(input())
    for bingo in bingo_list:
        if num in bingo:
            bingo.remove(num)
            if not bingo:
                is_bingo = True

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

Submission status: Wrong Answer

Solution code:
import sys
nums = []
patterns = []
for i in range(3):
    line = sys.stdin.readline().strip()
    a, b, c = map(int, line.split())
    nums.append([a,b,c])
    patterns.append([a,b,c])
patterns = []
# vertical
for i in range(3):
    patterns.append([nums[0][i], nums[1][i], nums[2][i]])
patterns.append([nums[0][0], nums[1][1], nums[2][2]])
patterns.append([nums[0][2], nums[1][1], nums[2][0]])

line = sys.stdin.readline().strip()
n = int(line)
tests = []
for i in range(n):
    line = sys.stdin.readline().strip()
    tests.append(int(line))
for p in patterns:
    if p[0] in tests and p[1] in tests and p[2] in tests:
        print('Yes')
        sys.exit(0)
print('No')

Submission status: Wrong Answer

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

flag = False

for i in range(3):
    if all([True if j in b else False for j in a_list[i]]):
        print('Yes')
        flag = True
        break

if flag == False:
    for i in range(3):
        if all([True if a_list[i][j] in b else False for j in range(3)]):
            print('Yes')
            flag = True
            break

if flag == False:
    temp1 = [(0,0), (1,1), (2,2)]
    temp2 = [(0,2), (1,1), (2,0)]
    if all([True if a_list[i][j] in b else False for (i,j) in temp1]):
        print('Yes')
        flag = True

    if all([True if a_list[i][j] in b else False for (i,j) in temp2]):
        print('Yes')
        flag = True
    
if flag == False:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(3):
    if A[i] <= B or (A[0][i] in B and A[1][i] in B and A[2][i] in B):
        print('Yes')
        sys.exit()

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

print('No')

Submission status: Wrong Answer

Solution code:
A = [[],[],[]]
A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))
check = [[True for _ in range(3)] for _ in range(3)]
cnt = [0 for _ in range(8)]
for i in range(3):
    if (A[i][0] in b) and check[i][0]:
        cnt[0] += 1
        check[i][0] = False
    if (A[i][1] in b) and check[i][1]:
        cnt[1] += 1
        check[i][1] = False
    if (A[i][2] in b) and check[i][2]:
        cnt[2] += 1
        check[i][2] = False
    if (A[0][i] in b) and check[0][i]:
        cnt[3] += 1
        check[0][i] = False
    if (A[1][i] in b) and check[1][i]:
        cnt[4] += 1
        check[1][i] = False
    if (A[2][i] in b) and check[2][i]:
        cnt[5] += 1
        check[2][i] = False
    if (A[i][i] in b) and check[i][i]:
        cnt[6] += 1
        check[i][i] = False
    if (A[i][2-i] in b) and check[i][2-i]:
        cnt[7] += 1
        check[i][2-i] = False
if sum(cnt) > 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for i in range(N):
    num = int(input())
    if bingo.count(num) > 0:
        idx = bingo.index(num)
        bingo[idx] = 0

if bingo[0] == 0 and bingo[1] == 0 and bingo[2] == 0:
    print('Yes')
elif bingo[0] == 0 and bingo[3] == 0 and bingo[6] == 0:
    print('Yes')
elif bingo[0] == 0 and bingo[4] == 0 and bingo[8] == 0:
    print('Yes')
elif bingo[2] == 0 and bingo[4] == 0 and bingo[6] == 0:
    print('Yes')
elif bingo[2] == 0 and bingo[5] == 0 and bingo[8] == 0:
    print('Yes')
elif bingo[6] == 0 and bingo[7] == 0 and bingo[8] == 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())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == A[j][k]:
                A[j][k] = 0

if sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 or A[0][0]+A[1][1]+A[2][2]==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()))
N = int(input())

B = list(int(input()) for i in range(N))

ans = 0
for a in A1:
  if a in B:
    ans += 1
if ans == 3:
  print('Yes')
else:
  ans = 0
  for a in A2:
    if a in B:
      ans += 1
  if ans==3:
    print('Yes')
  else:
    ans = 0
    for a in A3:
      if a in B:
        ans += 1
    if ans==3:
      print('Yes')  
    else:
      ans = 0
      for a in [A1[0], A2[0], A3[0]]:
        if a in B:
          ans += 1
      if ans==3:
        print('Yes') 
      else:
        ans = 0
        for a in [A1[1], A2[1], A3[1]]:
          if a in B:
            ans += 1
        if ans==3:
          print('Yes')
        else:
          ans = 0
          for a in [A1[2], A2[2], A3[2]]:
            if a in B:
              ans += 1
          if ans==3:
            print('Yes')
          else:
            ans = 0
          for a in [A1[0], A2[1], A3[2]]:
            if a in B:
              ans += 1
          if ans==3:
            print('Yes')
          else:
            ans = 0
            for a in [A1[2], A2[1], A3[0]]:
              if a in B:
                ans += 1
            if ans==3:
              print('Yes')

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
aa = list(zip(*a))
n = int(input())
b = [int(input()) for _ in range(n)]
if a[0] in b or a[1] in b or a[2] in b or aa[0] in b or aa[1] in b or aa[2] in b:
    print('Yes')
elif a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
elif a[0][2] in b and a[1][1] in b and a[2][0] in b:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if A[0][0] in b and A[0][1] in b and A[0][2] in b:
    ok = True
elif A[1][0] in b and A[1][1] in b and A[1][2] in b:
    ok = True
elif A[2][0] in b and A[2][1] in b and A[2][2] in b:
    ok = True
elif A[0][0] in b and A[1][0] in b and A[2][0] in b:
    ok = True
elif A[0][1] in b and A[1][1] in b and A[2][1] in b:
    ok = True
elif A[0][0] in b and A[1][1] in b and A[2][2] in b:
    ok = True
elif A[0][2] in b and A[1][1] in b and A[2][0] in b:
    ok = True
    
if ok:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
    bingo = [input().split(" ") for _ in range(3)]
    n = int(input())
    hit = []
    line = [[],[],[]]
    cross1 = []
    cross2 = []
    for _ in range(n):
        num = input()
        found = False
        for i in range(3):
            for j in range(3):
                if bingo[i][j] == num:
                    found = True
                    if i == j:
                        cross1.append((i, j))
                    if i == 0 and j == 2:
                        cross2.append((i, j))
                    if i == 2 and j == 0:
                        cross2.append((i, j))
                    line[i].append((i, j))
                    continue
            if found:
                continue
    for l in line:
        if len(l) == 3:
            print("Yes")
            return
    if len(cross1) == 3:
        print("Yes")
    elif len(cross2) == 3:
        print("Yes")
    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)]

card = [[0 for _ in range(3)] for _ in range(3)]


for i in range(N):
    for x in range(3):
        for y in range(3):
            if A[x][y] == b[i]:
                card[x][y] = 1

ans = "No"

for i in range(3):
    if sum(card[i]) == 3:
        ans = "Yes"

if sum([card[i][i] for i in range(3)]) == 3:
    ans = "Yes"

if sum([card[i][2 - i] for i in range(3)]) == 3:
    ans = "Yes"

print(ans)

Submission status: Wrong Answer

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

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

n = int(input())
ans = "No"
for _ in range(n):
    b = int(input())
    for i in range(3):
        if b in grid[i]:
            grid[i][grid[i].index(b)] = 0
    if judge():
        ans = "Yes"

print (ans)

Submission status: Wrong Answer

Solution code:
from itertools import product

A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
bingo = [[0] * 3 for _ in range(3)]
for b in B:
    for i, j in product(range(3), repeat=2):
        if A[i][j] == b:
            bingo[i][j] = 1
            break
flag = False
for i in range(3):
    if sum(bingo[i]) == 3:
        flag = True
        break
else:
    for j in range(3):
        if sum(bingo[i][j] for i in range(3)) == 3:
            flag = True
            break
    else:
        if sum(bingo[i][i] for i in range(3)) == 3 or sum(bingo[i][2-i] for i in range(3)):
            flag = True
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
bingo = False
A = []
for _ in range(3):
  a = list(map(int, input().split()))
  A.append(a)
  
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] = 0

if sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[2]) == 0 or sum([A[0][0], A[0][1], A[0][2]]) == 0 or sum([A[1][0], A[1][1], A[1][2]]) == 0 or sum([A[2][0], A[2][1], A[2][2]]) == 0 or sum([A[0][0], A[1][1], A[2][2]]) == 0 or sum([A[2][0], A[1][1], A[0][2]]) == 0:
  bingo = True

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

Submission status: Wrong Answer

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

def main():
    A = [[int(i) for i in input().split()] for j in range(3)]
    N = int(readline())

    ans = [[0]*3 for _ in range(3)]
    for i in range(N):
        b = int(readline())
        for j, a in enumerate(A):
            for k, a_ in enumerate(a):
                if b == a_:
                    ans[j][k] = 1

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

    print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(N):
    b = int(input())
    for x in bingo:
        if x[0] == b:
            x[0] = True
        elif x[1] == b:
            x[1] = True
        elif x[2] == b:
            x[2] = True

        if x[0] == True and x[0] == True and x[1] == True:
            print("Yes")
            exit()

if bingo[0][0] == True and bingo[1][0] == True and bingo[2][0] == True:
    print("Yes")
    exit()
if bingo[0][1] == True and bingo[1][1] == True and bingo[2][1] == True:
    print("Yes")
    exit()
if bingo[0][2] == True and bingo[1][2] == True and bingo[2][2] == True:
    print("Yes")
    exit()

if bingo[0][0] == True and bingo[1][1] == True and bingo[2][2] == True:
    print("Yes")
    exit()
if bingo[0][2] == True and bingo[1][1] == True and bingo[2][0] == True:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

a = []
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
a.append([int(i) for i in input().split()])
n = int(input())
c = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                c[j][k] = 1

flag = False

for i in range(3):
    if c[0][i] + c[1][i] + c[2][i] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    if c[i][0] + c[i][1] + c[i][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break
    if c[i%3][0] + c[(i+1)%3][1] + c[(i+2)%3][2] == 3 and flag == False:
        print("Yes")
        flag = True
        break