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:
rows = []
for i in range(3):
    row = [int(x) for x in input().split()]
    rows.append(row)

N = int(input())
choice = []
for j in range(N):
    choice.append(int(input()))


for row in rows:
    match = [c for c in choice if c in row]

    if (len(match) >= 3):
        print("Yes")
        break
else:
    columns = []
    for k in range(3):
        column = [rows[l][k] for l in range(3)]
        columns.append(column)

    for column in columns:
        match = [c for c in choice if c in column]

        if (len(match) >= 3):
            print("Yes")
            break
    else:
        left = []
        for m in range(3):
            left.append(rows[m][m])

        right = []
        for n in range(3):
            for o in range(3)[::-1]:
                right.append(rows[n][o])

        match_left = [c for c in choice if c in left]
        match_right = [c for c in choice if c in right]

        if (len(match_left) >= 3):
            print("Yes")
        elif (len(match_right) >= 3):
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
# ABC157b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと
    bing = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for num in b:
        for i in bing:
            try:
                while True:
                    t = i.index(num)
                    i[t] = -1
            except:
                continue
    # print(bing)

    naname = [((0, 0), (1, 1), (2, 2)), (2, 0), (1, 1), (0, 2)]
    if sum(bing[0]) == -3 or sum(bing[1]) == -3 or sum(bing[2]) == -3 or bing[0][0]+bing[1][0]+bing[2][0] == -3 or bing[0][1]+bing[1][1]+bing[2][1] == -3 or bing[0][2]+bing[0][2]+bing[0][2] == -3 or bing[0][0]+bing[1][1]+bing[2][2] == -3 or bing[0][2]+bing[1][1]+bing[2][0] == -3:
        print('Yes')
        exit(0)

    print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def main():
    lst = []
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    lst += list(map(int,input().split()))
    n = int(input())


    for _ in range(n):
        temp = int(input())
        if temp in lst:
            i = lst.index(temp)
            lst[i] = False
    answer = "No"
    if not all((lst[0],lst[1],lst[2])) or not all((lst[3],lst[4],lst[5])) or not all((lst[6],lst[7],lst[8])):
        answer = "Yes"
    if not all((lst[0],lst[3],lst[6])) or not all((lst[1],lst[4],lst[7])) or not all((lst[2],lst[5],lst[8])):
        answer = "Yes"
    if not all((lst[0],lst[4],lst[8])) or not all((lst[2],lst[4],lst[6])):
        answer = "Yes"
    print(answer)










if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

N = int(input())

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

result = "No"

if((A[0][0] in B) and (A[0][1] in B) and (A[0][2] in B)):
  result = "Yes"
if(A[1][0] in B and A[1][1] in B and A[1][2] in B):
  result = "Yes"
if(A[2][0] in B and A[2][1] in B and A[2][2] in B):
  result = "Yes"
if(A[0][0] in B and A[1][0] in B and A[1][0] in B):
  result = "Yes"
if(A[0][1] in B and A[1][1] in B and A[2][1] in B):
  result = "Yes"
if(A[0][2] in B and A[1][2] in B and A[2][2] in B):
  result = "Yes"
if(A[0][0] in B and A[1][1] in B and A[2][2] in B):
  result = "Yes"
if(A[0][2] in B and A[1][1] in B and A[2][0] in B):
  result = "Yes"

print(result)

Submission status: Wrong Answer

Solution code:
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
lst3 = list(map(int, input().split()))
bng1=[0, 0, 0]
bng2=[0, 0, 0]
bng3=[0, 0, 0]
n = int(input())
for i in range(n):
    b = int(input())
    for i in range(len(lst1)):
        if b == lst1[i]:
            bng1[i] = 1
    for ii in range(len(lst2)):
        if b == lst2[ii]:
            bng2[ii] = 1
    for iii in range(len(lst3)):
        if b == lst3[iii]:
            bng3[iii] = 1
    if '0' in bng1 == False or '0' in bng2 == False or '0' in bng3 == False or bng1[0] * bng2[1] * bng3[2] != 0:
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
a = []
for i in range(3):
    a += list(map(int, input().split()))
n = int(input())
b = [int(input()) for i in range(n)]
answer = [False for i in range(9)]

for po in b:
    for i in range(9):
        if a[i] == po:
            answer[i] = True


for i in range(3):
    if answer[0+3*i] and answer[1+3*i] and answer[2+3*i]:
        print("Yestate")
        sys.exit()
    elif answer[0 + i] and answer[1 + i] and answer[2 + i]:
        print("Yesyoko")
        sys.exit()
if answer[0] and answer[4] and answer[8]:
    print("Yes")
elif answer[2] and answer[4] and answer[6]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

print("No")

Submission status: Wrong Answer

Solution code:
import itertools
a = []
cnt_list = []
for _ in range(3):
    a += map(int, input().split())
n = int(input())
for _ in range(n):
    b = int(input())
    for i, j in enumerate(a):
        if b == j:
            cnt_list.append(i)
ans = 'No'
if len(cnt_list) > 2:
    for k in list(itertools.permutations(cnt_list, 3)):
        if sum(k) % 3 == 0:
            ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
listA = []
import itertools
listB = [0] * 9
for i in range(3):
    listA.append(input().split())
listA = list(itertools.chain.from_iterable(listA))
N = int(input())
for i in range(N):
    B = input()
    if B in listA:
        listB[listA.index(B)] = 1
for i in range(3):
    if listB[i:(i+1)*3-1].count(1) == 3:
        print("Yes")
        exit()
for i in range(3):
    if listB[i*3] == 1 and listB[i*3+1] == 1 and listB[i*3+2] == 1:
        print("Yes")
        exit()
if listB[0] == 1 and listB[4] == 1 and listB[8] == 1:
    print("Yes")
    exit()
if listB[2] == 1 and listB[4] == 1 and listB[6] == 1:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

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

if ans != 'Yes':
    for j in range(3):
        if mark[0][j] and mark[1][j] and mark[2][j]:
            ans = 'Yes'
            break

if ans != 'Yes':
    if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]): ans = 'Yes'
print(ans)

Submission status: Wrong Answer

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

for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] in B[k]:
                A[i][j] = 0
if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0 or A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0 or A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0 or A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0 or A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0 or A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0 or A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0 or A[0][2] == 0 and A[1][1] == 0 and A[0][2] == 0:
    print("Yes")
else:
    print("No")
print(B)

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()))
n = int(input())
b = [int(input()) for _ in range(n)]

# 横
for num1 in A_1:
  if num1 in b:
    continue
  else:
    break
  print('Yes')
  exit(0)
  
for num2 in A_2:
  if num2 in b:
    continue
  else:
    break
  print('Yes')
  exit(0)

for num3 in A_3:
  if num3 in b:
    continue
  else:
    break
  print('Yes')
  exit(0)
  
# 縦
for j in range(3):
  if A_1[j] in b:
    if A_2[j] in b:
      if A_3[j] in b:
        print('Yes')
        exit(0)
# 斜め
if A_1[0] in b:
  if A_2[1] in b:
    if A_3[2] in b:
      print('Yes')
      exit(0)
      
if A_1[2] in b:
  if A_2[1] in b:
    if A_3[0] in b:
      print('Yes')
      exit(0)

print('No')

Submission status: Wrong Answer

Solution code:
def cal(lst1, lst2, lst3):
    for i in range(3):
        if lst1[i] in lst3:
            lst2[i] = 1

def judge(a, b, c):
    if a == 1 and (a == b == c):
        return True
    else:
        return False

A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]
C_1 = [0, 0, 0]
C_2 = [0, 0, 0]
C_3 = [0, 0, 0]
cal(A_1, C_1, b)
cal(A_2, C_2, b)
cal(A_3, C_3, b)

a = judge(C_1[0], C_2[0], C_3[0])
b = judge(C_1[1], C_2[1], C_3[1])
c = judge(C_1[2], C_2[2], C_3[2])

d = judge(C_1[0], C_1[1], C_1[2])
e = judge(C_2[0], C_2[1], C_2[2])
f = judge(C_3[0], C_3[1], C_3[2])

g = judge(C_1[0], C_2[1], C_3[2])
h = judge(C_1[2], C_2[1], C_3[0])

lst = [a, b, c, d, e, f, g]
if True in lst:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
li_d = [li_a[0], li_b[0], li_c[0]]
li_e = [li_a[1], li_b[1], li_c[1]]
li_f = [li_a[2], li_b[2], li_c[2]]
li_g = [li_a[0], li_b[1], li_c[2]]
li_h = [li_a[2], li_b[1], li_c[0]]
n = int(input())
li_call = []
for i in range(n):
  li_call.append(int(input()))
for i in range(n):
  for j in range(2):
    if li_a[j] == li_call[i]:
      li_a[j] = 0
  for k in range(2):
    if li_b[k] == li_call[i]:
      li_b[k] = 0
  for l in range(2):
    if li_c[l] == li_call[i]:
      li_c[l] = 0
li_o = 0
if li_a == li_o or li_b == li_o or li_c == li_o or li_d == li_o or li_e == li_o or li_f == li_o or li_g == li_o or li_h == [0, 0, 0]:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A_11,A_12,A_13=(int(x) for x in input().split())
B_11,B_12,B_13=(int(x) for x in input().split())
C_11,C_12,C_13=(int(x) for x in input().split())
N=int(input())
#A=list(map(int, input().split()))

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

if (A_11 and A_12 and A_13) in l:
    print('Yes')
elif (B_11 and B_12 and B_13) in l:
    print('Yes')
elif (C_11 and C_12 and C_13) in l:
    print('Yes')
elif (A_11 and B_11 and C_11) in l:
    print('Yes')
elif (A_12 and B_12 and C_12) in l:
    print('Yes')
elif (A_13 and B_13 and C_13) in l:
    print('Yes')
elif (A_11 and B_12 and C_13) in l:
    print('Yes')
elif (C_11 and B_12 and A_13) in l:
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(int(1e6))

A = [[0]*3]*3
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 = [0] * N
for i in range(N):
    b[i] = int(input())

card = [[0]*3]*3
n = 0
for bn in b:
    for m in range(3*3):
        i = m % 3
        j = m // 3
        if (A[i][j] == bn):
            card[i][j] = 1
            break

ans = 'No'
for i in range(3):
    if sum(A[i]) == 3:
        ans = 'Yes'
        break
    if sum([A[0][i], A[1][i], A[2][i]]) == 3:
        ans = 'Yes'
        break
else:
    if sum([A[0][0], A[1][1], A[2][2]]) == 3:
        ans = 'Yes'
    elif sum([A[2][0], A[1][1], A[0][2]]) == 3:
        ans = 'Yes'

print(ans)

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:
    print('Yes')
    exit()
if a[1] in b:
    print('Yes')
    exit()
if a[2] in b:
    print('Yes')
    exit()
if aa[0] in b:
    print('Yes')
    exit()
if aa[1] in b:
    print('Yes')
    exit()
if aa[2] in b:
    print('Yes')
    exit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print('Yes')
    exit()
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:

l1=list(map(int ,input().split()))
l2=list(map(int ,input().split()))
l3=list(map(int ,input().split()))
l4=[l1[0],l2[1],l3[2]]
l5=[l1[2],l2[1],l3[0]]
n = int(input())
l=[int(input()) for x in range(n)]

print(l4)
print(l5)

if l1[0] and l1[1] and l1[2] in l:
    print("Yes")
elif l2[0] and l2[1] and l2[2] in l:
    print("Yes")
elif l3[0] and l3[1] and l3[2] in l:
    print("Yes")
elif l4[0] and l4[1] and l4[2] in l:
    print("Yes")
elif l5[0] and l5[1] and l5[2] in l:
    print("Yes")
elif l1[0] and l2[0] and l3[0] in l:
    print("Yes")
elif l1[1] and l2[1] and l3[1] in l:
    print("Yes")
elif l1[2] and l2[2] and l3[2] in l:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

# print(A)
N = int(input())

for i in range(0, N):
  data = int(input())
  if data in A:
    A[A.index(data)] = 0

if sum(A[0:3]) == 0 or sum(A[3:6]) == 0 or sum(A[3:6]) == 0 or A[0] + A[4] + A[8] == 0 or A[2] + A[4] + A[6] == 0:
  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"
  
print(judge)

Submission status: Wrong Answer

Solution code:
b1=list(map(int,input().split()))
b2=list(map(int,input().split()))
b3=list(map(int,input().split()))
n=int(input())

for i in range(n):
    bb=int(input())
    for j in range(3):
        if bb==b1[j]:
            b1[j]=0
        elif bb==b2[j]:
            b2[j]=0
        elif bb==b3[j]:
            b3[j]=0
if sum(b1)==0 or sum(b2)==0 or sum(b3)==0:
    print("Yes")
elif b1[0]==b2[0]==b3[0]==0:
    print("Yes")
elif b1[1]==b2[1]==b3[1]==0:
    print("Yes")
elif b1[1]==b2[1]==b3[1]==0:
    print("Yes")

    
elif b1[0]==b2[1]==b3[2]==0:
    print("Yes")
elif b1[2]==b2[1]==b3[0]==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())

def judge(a, n):
    if n <= 2:
        return False
    elif n >= 6:
        return True
    else:
        if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0:
            return True
        elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0:
            return True
        elif a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0:
            return True
        elif a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0:
            return True
        elif a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0:
            return True
        elif a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0:
            return True
        elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
            return True
        elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
            return True
        return False
    

for i in range(n):
    num = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == num:
                a[x][y] = 0

if judge(a, n):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))

flag = 0
A = np.hstack([A1,A2,A3])
#print(A)
#print(b)

for i in range(N):
  for j in range(3):
    if b[i] == A1[j]:
      A1[j] = 0
    elif b[i] == A2[j]:
      A2[j] = 0
    elif b[i] == A3[j]:
      A3[j] = 0
if A2[1] == 0:
  if A2[0] == 0 and A2[2] == 0:
    flag = 1
  elif A1[1] == 0 and A3[1] == 0:
    flag = 1
  elif A1[0] == 0 and A3[2] == 0:
    flag = 1
  elif A1[2] == 0 and A2[0] == 0:
    flag = 1
elif A1[0] == 0 and A1[1] == 0 and A1[2] == 0:
  flag = 1
elif A1[0] == 0 and A1[0] == 0 and A2[0] == 0:
  flag = 1
elif A1[2] == 0 and A1[2] == 0 and A2[2] == 0:
  flag = 1
elif A3[0] == 0 and A3[1] == 0 and A3[2] == 0:
  flag = 1
if flag == 1:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

b = []

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


for i in range(len(A[0])):
  if (A[0][i] != 0 and A[i][0] != 0 and A[i][i] != 0) and (A[1][i] != 0 and A[i][1] != 0) and (A[2][i] != 0 and A[i][2] != 0):
    if A[0][2] == A[1][1] == A[2][0]:
      print("Yes")
    else:
      print("No")
    break

  if i == 2:
    print("Yes")

Submission status: Wrong Answer

Solution code:
gyo1 = list(map(int,input().split()))
gyo2 = list(map(int,input().split()))
gyo3 = list(map(int,input().split()))

n = int(input())
for i in range(n):
  detame = int(input())
  if detame in gyo1:
    gyo1[gyo1.index(detame)] = -1
  elif detame in gyo2:
    gyo2[gyo2.index(detame)] = -1
  elif detame in gyo3:
    gyo3[gyo3.index(detame)] = -1
    
if gyo1.count(-1) == 3 or gyo2.count(-1) == 3 or gyo3.count(-1) == 3:
  print('Yes')
  exit()

for i in range(2):
  if gyo1[i] == -1 and gyo2[i] == -1 and gyo3[i] == -1 :
    print('Yes')
    exit()
    
if gyo1[0] == -1 and gyo2[1] == -1 and gyo3[2] == -1 : 
  print('Yes')
elif gyo1[2] == -1 and gyo2[1] == -1 and gyo3[0] == -1 : 
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

n = int(input())
b_s = []
for i in range(n):
    b_s.append(int(input()))
ans = "No"


for i in range(n):
    for j in range(3):
        for k in range(3):
            if b_s[i] == bingo[j][k]:
                bingo[j][k] = "o"

if bingo[1][1] == "o":
    if bingo[0][0] == "o" and bingo[2][2] == "o":
        ans = "Yes"
    elif bingo[0][2] == "o" and bingo[2][1] == "o":
        ans = "Yes"
    elif bingo[1][0] == "o" and bingo[1][2] == "o":
        ans = "Yes"
    elif bingo[0][1] == "o" and bingo[2][1] == "o":
        ans = "Yes"

elif bingo[1][1] != "o":
    if bingo[0][0] == "o" and bingo[0][1] == "o" and bingo[0][2] == "o":
        ans = "Yes"
    elif bingo[0][0] == "o" and bingo[1][0] == "o" and bingo[2][0] == "o":
        ans = "Yes"
    elif bingo[0][2] == "o" and bingo[1][2] == "o" and bingo[2][2] == "o":
        ans = "Yes"
    elif bingo[2][0] == "o" and bingo[2][1] == "o" and bingo[2][2] == "o":
        ans = "Yes"

print(ans)

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 _ in range(N)]

cnt1 = 0
for i in A1:
    if i in b:
        cnt1 += 1
    if cnt1 == 3:
        flag1 = 1
    else:
        flag1 = 0

cnt2 = 0
for i in A2:
    if i in b:
        cnt2 += 1
    if cnt2 == 3:
        flag2 = 1
    else:
        flag2 = 0

cnt3 = 0
for i in A3:
    if i in b:
        cnt3 += 1
    if cnt3 == 3:
        flag3 = 1
    else:
        flag3 = 0

cnt4 = 0
for i in [A1[0], A2[1], A3[2]]:
    if i in b:
        cnt4 += 1
    if cnt4 == 3:
        flag4 = 1
    else:
        flag4 = 0

if flag1 == 1 or flag2 == 1 or flag3 == 3 or flag4 == 1:
    print('Yes')
else:
    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)]
def bingo(A,b):
    c = [[0,0,0],[0,0,0],[0,0,0]]
    for i in range(0,len(b)):
        for j in range(0,3):
            for k in range(0,3):
                if A[j][k] == b[i]:
                    c[j][k] = 1
    if c[0] == [1,1,1] or c[1] == [1,1,1] or c[2] == [1,1,1]:
        return 'Yes'
    else:
        for i in range(0,3):
            for j in range(0,3):
                s = 0
                s = s + c[j][i]
            if s == 3:
                return 'Yes'
        if c[0][0] == c[1][1] == c[2][2] == 1 or c[0][2] == c[1][1] == c[2][0] == 1:
            return 'Yes'
        else:
            return 'No'
print(bingo(A,b))

Submission status: Wrong Answer

Solution code:
card = [[],[],[]]

isBingo = False

for n in range(3):
    rawInput = input().split()
    for m in rawInput:
        card[n].append(int(m))

N = int(input())

shirushi = []

for n in range(N):
    shirushi.append(int(input()))

markedhairetu = [[False,False,False],[False,False,False],[False,False,False]]

for p in range(3):
    for q in range(3):
        for r in range(N):
            if shirushi[r] == card[p][q]:
                markedhairetu[p][q] = True

for n in range(3):
    if markedhairetu[n].count(True) == 3:
        isBingo = True

for ind in range(3):
        if markedhairetu[ind][0] == True and markedhairetu[ind][1] == True and markedhairetu[ind][2] == True:
            isBingo = True

if markedhairetu[0][0] == True and markedhairetu[1][1] == True and markedhairetu[2][2] == True:
    isBingo = True

if markedhairetu[2][0] == True and markedhairetu[1][1] == True and markedhairetu[0][2] == True:
    isBingo = True

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

Submission status: Wrong Answer

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

tmp = []

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

ans = [[(0,0),(1,1),(2,2)],[(0,2),(1,1),(2,0)],[(0,0),(0,1),(0,2)],[(1,0),(1,1),(1,2)],[(2,0),(2,1),(2,2)],[(0,0),(0,1),(0,2)],[(1,0),(1,1),(1,2)],[(2,0),(2,1),(2,2)]]

for i in ans:
    count = 0
    for j in tmp:
        if j in i:
            count += 1
    if count == 3:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

from fractions import gcd
import math
from math import ceil,floor
import collections

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

def func(a):
   return tmp

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

ans="no"

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

for i in range(0,3):
    if A[i][0]==0 and A[i][1]==0 and A[i][2]==0:
        ans = "yes"

for i in range(0,3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        ans = "yes"

if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    ans = "yes"

if A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    ans = "yes"

print(ans)

Submission status: Wrong Answer

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

ans=[set([a[0][0],a[0][1],a[0][2]]),set([a[1][0],a[1][1],a[1][2]]),set([a[2][0],a[2][1],a[2][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]])]
from itertools import combinations
if n<3:
    print('No')
    exit()

for i in combinations(b, 3):
    if set(i) in ans:
        print('Yes')
        exit()
print('No')

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[i] += 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

def main():
    a=[]
    b=[]
    c=[]
    for i in range(3):
        tmp = input().replace('\n','').split(' ')
        tmp = list(map(int, tmp))
        a.append([tmp[0],False])
        a.append([tmp[1],False])
        a.append([tmp[2],False])
        c.append(tmp[0])
        c.append(tmp[1])
        c.append(tmp[2])
    n = int(input().replace('\n',''))
    for i in range(n):
        try:
            tmp = c.index(int(input().replace('\n','')))
            a[tmp][1] = True
        except ValueError:
            pass
    for i in range(3):
        if a[i][1] and a[i+3][1] and a[i+6]:
            res = 'Yes'
            break
        elif a[i*3][1] and a[i*3+1][1] and a[i*3+2][1]:
            res = 'Yes'
            break
        elif a[0][1] and a[4][1] and a[7][1] or a[2][1] and a[4][1] and a[6][1]:
            res = 'Yes'
            break
        else:
            res = 'No'
            break
    print(res)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

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()]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b: a1[j]=-1
        if a2[j]==b: a2[j]=-1
        if a3[j]==b: a3[j]=-1
print("Yes" if sum(a1)==-3 or sum(a2)==-3 or sum(a3)==-3 or a1[0]+a2[1]+a3[2]==-3 or a1[2]+a2[1]+a3[0]==-3 else "No" )

Submission status: Wrong Answer

Solution code:
A1,A2,A3=input().split()
A4,A5,A6=input().split()
A7,A8,A9=input().split()
N=int(input())
B=[input() for i in range(N)]
if(A1 in B):
  if(A2 in B):
    if(A3 in B):
      print("Yes")
  elif(A4 in B):
    if(A7 in B):
      print("Yes")
  elif(A5 in B):
    if(A9 in B):
      print("Yes")
elif(A2 in B):
  if(A5 in B):
    if(A8 in B):
      print("Yes")
elif(A3 in B):
  if(A6 in B):
    if(A9 in B):
      print("Yes")
  elif(A5 in B):
    if(A7 in B):
      print("Yes")
elif(A4 in B):
  if(A5 in B):
    if(A6 in B):
      print("Yes")
elif(A7 in B):
  if(A8 in B):
    if(A9 in B):
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
Bingo = [ list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
Bingo.append([Bingo[0][0] , Bingo[1][1],Bingo[2][2] ])
Bingo.append([Bingo[0][2] , Bingo[1][1],Bingo[2][0] ])
k=0
re = 'No'
for l in range(3):
  if len(list(set(num) & set(Bingo[l]))) == 3:
    re = 'Yes'
    break
print(re)

Submission status: Wrong Answer

Solution code:
AA = list(map(int, input().split()))
AB = list(map(int, input().split()))
AC = list(map(int, input().split()))
N = int(input())

for i in range(N):
  B = int(input())
  for j in range(3):
    if AA[j] == B:
      AA[j] = 0
    elif AB[j] == B:
      AB[j] = 0
    elif AC[j] == B:
      AC[j] = 0

A = "No"

if AA[0] == 0:
  if (AA[1] == 0 and AA[2] == 0) or(AB[1] == 0 and AC[2] ==0):
    A = "Yes"
if AA[1] == 0:
  if AB[1] == 0 and AC[1] == 0:
    A = "Yes"
if AA[2] == 0:
  if (AB[2] == 0 and AC[2] == 0) or (AB[1] == 0 and AC[0] == 0):
    A = "Yes"
if AB[0] == 0:
  if AB[1] == 0 and AB[2] == 0:
    A = "Yes"
if AC[0] == 0:
  if AC[1] == 0 and AC[2] == 0:
    A = "Yes"
    
print(A)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# @Time    : 2020/3/1 19:59
# @Author  : DIRICHLET
# @File    : main.py


b=[[0,0,0]]*3
#print(b)
m={}
for i in range(3):
    t=list(map(int,input().split()))
    k=0
    for j in t:
        m[j]=(i,k)
        k+=1
n=int(input())
for i in range(n):
    t=int(input())
    if t in m:
        #print(m[t])
        b[m[t][0]][m[t][1]]=1
for i in b:
    ans=1
    for j in i:
        ans*=j
    if ans==1:
        print('Yes')
        exit()
for i in range(3):
    ans=1
    for j in range(3):
        ans*=b[j][i]
    if ans==1:
        print('Yes')
        exit()
if b[0][0]*b[1][1]*b[2][2]==1:
    print('Yes')
    exit()
if b[0][2]*b[1][1]*b[2][0]==1:
    print('Yes')
    exit()
print('No')

Submission status: Wrong Answer

Solution code:
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
atari=[]
for i in range(3):
    atari.append([a[i][0],a[i][1],a[i][2]])
for i in range(3):
    atari.append([a[0][i],a[0][i],a[0][i]])
atari.append([a[0][0],a[1][1],a[2][2]])
atari.append([a[0][2],a[1][1],a[2][0]])
for k in range(len(atari)):
    if len(list(set(atari[k]) & set(b)))==3:
        print("Yes")
        break
else:
    print("No")