Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All values in input are integers.

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

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

1 \leq N \leq 10

1 \leq b_i \leq 100

b_i \neq b_j (i \neq j)

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

Sample Input 2

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

Sample Output 2

No

We will mark nothing.

Sample Input 3

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

Sample Output 3

Yes

We will mark all the squares.



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


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys

def check(x):
  if(x[0] == 0 and x[1] == 0 and x[2] == 0):
    return 1
  else:
    return 0

def main():
  a1 = list(map(int, input().split()))
  a2 = list(map(int, input().split()))
  a3 = list(map(int, input().split()))
  num = int(input())
  a9 = a1 + a2 + a3
  x = 0
  z = [int(input()) for i in range(num)]
  for i in z:
    for k, name in enumerate(a9):
      if(i == name):
        a9[k] = 0
  
  a4 = []
  a5 = []
  a6 = []
  a7 = []
  a8 = []  
  a4.extend([a9[0],a9[3],a9[6]])
  a5.extend([a9[1],a9[4],a9[7]])
  a6.extend([a9[2],a9[5],a9[8]])
  a7.extend([a9[0],a9[4],a9[8]])
  a8.extend([a9[2],a9[4],a9[6]])

  check_list = []
  check_list.append(check(a1))
  check_list.append(check(a2))
  check_list.append(check(a3))
  check_list.append(check(a4))
  check_list.append(check(a5))
  check_list.append(check(a6))
  check_list.append(check(a7))
  check_list.append(check(a8))

  count = 0
  for i in check_list:
    if(i == 1):
      print('Yes')
      x = 1
      sys.exit()
    count += 1
    if(count == num):
      sys.exit()
   
  if(x == 0):
    print('No')

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys

def check(x):
  if(x[0] == 0 and x[1] == 0 and x[2] == 0):
    return 1
  else:
    return 0

def main():
  a1 = list(map(int, input().split()))
  a2 = list(map(int, input().split()))
  a3 = list(map(int, input().split()))
  num = int(input())
  a9 = a1 + a2 + a3
  x = 0
  z = [int(input()) for i in range(num)]
  for i in z:
    for k, name in enumerate(a9):
      if(i == name):
        a9[k] = 0
  
  a4 = []
  a5 = []
  a6 = []
  a7 = []
  a8 = []  
  a4.extend([a9[0],a9[3],a9[6]])
  a5.extend([a9[1],a9[4],a9[7]])
  a6.extend([a9[2],a9[5],a9[8]])
  a7.extend([a9[0],a9[4],a9[8]])
  a8.extend([a9[2],a9[4],a9[6]])

  check_list = []
  check_list.append(check(a1))
  check_list.append(check(a2))
  check_list.append(check(a3))
  check_list.append(check(a4))
  check_list.append(check(a5))
  check_list.append(check(a6))
  check_list.append(check(a7))
  check_list.append(check(a8))

  for i in check_list:
    if(i == 1):
      print('Yes')
      x = 1
      sys.exit()
   
  if(x == 0):
    print('No')

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
a = list(list(map(int,input().split())) for i in range(3))
n = int(input())
b = [int(input()) for x in range(n)]
d = [[0]*3]*3
ans = "No"
for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                d[i][j] = 1
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[i][j]
    if c == 3:
        ans = "Yes"
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[j][i]
    if c == 3:
        ans = "Yes"
c = 0
for j in range(3):
    c+=d[j][j]
if c == 3:
    ans = "Yes"
c = 0
for j in range(3):
    c+=d[j][2-j]
if c == 3:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
a = list(list(map(int,input().split())) for i in range(3))
n = int(input())
b = [int(input()) for x in range(n)]
d = [[0]*3]*3
ans = "No"
for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                d[i][j] = 1
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[i][j]
    if c == 3:
        ans = "Yes"
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[j][i]
    if c == 3:
        ans = "Yes"
c = 0
for j in range(3):
    c+=d[j][j]
    if c == 3:
        ans = "Yes"
c = 0
for j in range(3):
    c+=d[j][2-j]
    if c == 3:
        ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
K=[['x','x','x'],
   ['x','x','x'],
   ['x','x','x']]
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,j=map(int,input().split())
N=int(input())
B=[]
for _ in range(N):
    B.append(int(input()))

for i in range(N):
  if B[i]==a:
    K[0][0]='o'
  if B[i]==b:
    K[0][1]='o'
  if B[i]==c:
    K[0][2]='o'
  if B[i]==d:
    K[1][0]='o'
  if B[i]==e:
    K[1][1]='o'
  if B[i]==f:
    K[1][2]='o'
  if B[i]==g:
    K[2][0]='o'
  if B[i]==h:
    K[2][1]='o'
  if B[i]==j:
    K[2][2]='o'

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

Submission status: Wrong Answer

Solution code:
a = list(list(map(int,input().split())) for i in range(3))
n = int(input())
b = [int(input()) for x in range(n)]
d = [[0]*3]*3
ans = "No"
for x in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[x]:
                d[i][j] = 1
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[i][j]
    if c == 3:
        ans = "Yes"
for i in range(3):
    c = 0
    for j in range(3):
        c+=d[j][i]
    if c == 3:
        ans = "Yes"
c = 0
for j in range(3):
    c+=d[j][j]
    if c == 3:
        ans = "Yes"
        c = 0
for j in range(3):
    c+=d[j][2-j]
    if c == 3:
        ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
a1 = input().split()
a2 = input().split()
a3 = input().split()
n = int(input())
ans = "No"
x = [0] * 9
for i in range(n):
    b = input()
    if b in a1:
        x[a1.index(b)] = 1
    if b in a2:
        x[a2.index(b)+3] = 1
    if b in a3:
        x[a3.index(b)+6] = 1

if x[0]+x[1]+x[2]==3 or x[3]+x[4]+x[5]==3 or x[6]+x[7]+x[8]==3 or x[0]+x[3]+x[6]==3 or x[1]+x[4]+x[7]==3 or x[2]+x[5]+x[8]==3 or x[0] + x[4] + x[8] == 3 or x[2]+x[4]+x[6]==3:
    ans = "Yes"
print(x)
print(ans)

Submission status: Wrong Answer

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
c = [
        a[0], a[1], a[2], a[::3], a[1::3], a[2::3],
        [a[0][0], a[1][1], a[2][2]], [a[0][2], a[1][1], a[2][0]]
    ]
a = a[0] + a[1] + a[2]
n = int(input())
b = [int(input()) for _ in range(n)]


same = set(a) & set(b)

for d in c:
    cnt = 0
    for n in same:
        if n in d:
            cnt += 1
    if cnt == 3:
        print("Yes")
        exit()
else:
    print("No")

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc157/tasks/abc157_b"

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

    n = int(input())
    exsit = [int(input()) for i in range(n)]
    for e in exsit:
        for b in bingo:
            if b.count(e) == 1:
                b[b.index(e)] = 0
    naname = [0, 0]
    for i in range(len(bingo)):
        if bingo[i].count(0) == 3:
            print('Yes')
            exit()
        elif [bingo[i][j] for j in range(3)].count(0) == 3:
            print('Yes')
            exit()
        naname[0] += 1 if bingo[i][i] == 0 else 0
        naname[1] += 1 if bingo[i][2 - i] == 0 else 0

    if naname[0] == 3 or naname[1] == 3:
        print('Yes')
    else:
        print('No')




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc157/tasks/abc157_b"

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

    n = int(input())
    exsit = [int(input()) for i in range(n)]
    for e in exsit:
        for b in bingo:
            if b.count(e) == 1:
                b[b.index(e)] = 0
    naname = [0, 0]
    for i in range(len(bingo)):
        if bingo[i].count(0) == 3:
            print('Yes')
            exit()
        elif [bingo[i][j] for j in range(3)].count(0) == 3:
            print('Yes')
            exit()
        naname[0] += 1 if bingo[i][i] == 0 else 0
        naname[1] += 1 if bingo[i][2 - i] == 0 else 0

    if naname[0] == 3 or naname[1]:
        print('Yes')
    else:
        print('No')




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
card = []

for _ in range(3):
    card.append(list(map(int, input().split())))

n = int(input())

b = []

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

for i in range(3):
    if card[i][0] in b and card[i][1] in b and card[i][2] in b:
        print('Yes')
        exit()
for i in range(3):
    if card[0][i] in b and card[1][i] in b and card[2][i] in b:
        print('Yes')
        exit()
if card[0][0] and card[1][1] and card[2][2]:
    print('Yes')
    exit()
if card[0][2] and card[1][1] and card[2][0]:
    print('Yes')
    exit()


print('No')

Submission status: Wrong Answer

Solution code:
card = []

for _ in range(3):
    card.append(list(map(int, input().split())))

n = int(input())

b = []

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

ans = "No"

for i in range(3):
    if card[i][0] in b and card[i][1] in b and card[i][2] in b:
        ans = "Yes"
for i in range(3):
    if card[0][i] in b and card[1][i] in b and card[2][i] in b:
        ans = "Yes"
if card[0][0] and card[1][1] and card[2][2]:
    ans = "Yes"
if card[0][2] and card[1][1] and card[2][0]:
    ans = "Yes"


print(ans)

Submission status: Wrong Answer

Solution code:
bingo = [[False] * 3] * 3

card = []

for _ in range(3):
    card.append(list(map(int, input().split())))

n = int(input())

b = []

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

for i in range(3):
    for j in range(3):
        for k in range(n):
            if card[i][j] == b[k]:
                bingo[i][j] = True

ans = "No"

for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2]:
        ans = "Yes"
for i in range(3):
    if bingo[0][i] and bingo[1][i] and bingo[2][i]:
        ans = "Yes"
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    ans = "Yes"
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
    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())
a = []
for i in range(n):
    b = int(input()) 
    a.append(b)
for i in range(3):
    if a1[i] in a and a2[i] in a and a3[i] in a:
        ans = 'Yes'
if a1[0] in a and a1[1] in a and a1[2] in a:
    ans = 'Yes'
if a2[0] in a and a2[1] in a and a3[2] in a:
    ans = 'Yes'
if a3[0] in a and a3[1] in a and a3[2] in a:
    ans = 'Yes'
if a1[0] in a and a2[1] in a and a3[2] in a:
    ans = 'Yes'
if a1[2] in a and a2[1] in a and a3[0] in a:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

m = int(input())
for i in range(m):
    num = int(input())
    if num in n: n[n.index(num)] = 0

check = "No"

for j in range(3):
    if n[j + 0] == 0 and n[j + 3] == 0 and n[j + 6] == 0:
        check = "Yes"
        break
    if n[j + 0] == 0 and n[j + 1] == 0 and n[j + 2] == 0:
        check = "Yes"
        break

if n[0] == 0 and n[4] == 0 and n[8] == 0:
        check = "Yes"
if n[2] == 0 and n[4] == 0 and n[6] == 0:
        check = "Yes"

print(check)

Submission status: Wrong Answer

Solution code:
def main():
    A = [[int(a) for a in input().split()] for i in range(3)]
    N = int(input())
    b = [int(input()) for i in range(N)]
    print(A, N, b)
    for k in b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == k:
                    A[i][j] = "x"
    bingo = False
    if A[0][0] == A[0][1] == A[0][2] == "x" or \
       A[1][0] == A[1][1] == A[1][2] == "x" or \
       A[2][0] == A[2][1] == A[2][2] == "x" or \
       A[0][0] == A[1][0] == A[2][0] == "x" or \
       A[0][1] == A[1][1] == A[2][1] == "x" or \
       A[0][2] == A[1][2] == A[2][2] == "x" or \
       A[0][0] == A[1][1] == A[2][2] == "x" or \
       A[0][2] == A[1][1] == A[2][0] == "x":
       bingo = True

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

Submission status: Wrong Answer

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

m = int(input())
for i in range(m):
    num = int(input())
    if num in n: n[n.index(num)] = 0

check = "No"

for j in range(3):
    if n[j * 0] == 0 and n[j * 1] == 0 and n[j * 2] == 0:
        check = "Yes"
        break
    if n[j + 0] == 0 and n[j + 1] == 0 and n[j + 2] == 0:
        check = "Yes"
        break

if n[0] == 0 and n[4] == 0 and n[8] == 0:
        check = "Yes"
if n[2] == 0 and n[4] == 0 and n[6] == 0:
        check = "Yes"

print(check)

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 = []
for n in range(N):
    B.append(int(input()))
ans='No'

def judge(A, B):
    for i in range(3): 
        if A[i] in B:
            A[i] = 1
        else:
            A[i] = 0

judge(A1, B)
judge(A2, B)
judge(A3, B)

if sum(A1)==3 or sum(A2)==3 or sum(A3)==3:
    ans = 'Yes' 
for i in range(3):
    if A1[i] + A2[i] + A3[i] == 1:
        ans = 'Yes'
if A1[0] + A2[1] + A3[2] == 3 or A1[2] + A2[1] + A3[0] == 3:
    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 = []
for n in range(N):
    B.append(int(input()))
ans='No'

#判定式
def judge(A, B):
    for i in range(3): 
        if A[i] in B:
            A[i] = 1
        else:
            A[i] = 0

#判定
judge(A1, B)
judge(A2, B)
judge(A3, B)

if sum(A1)==3 or sum(A2)==3 or sum(A3)==3:
    ans = 'Yes' 
for i in range(3):
    if A1[i] + A2[i] + A3[i] == 1:
        ans = 'Yes'
if A1[0] + A2[1] + A3[2] == 3 or A1[2] + A2[1] + A3[0] == 3:
    ans = 'Yes'

print(ans)

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

c=[a_1,a_2,a_3]

N=int(input())

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

for i in range(3):
    for j in range(3):
        if c[i][j] in b:
            c[i][j]=0
            
            
i=0
if c[0][0]==0 and c[0][1]==0 and c[0][2]:
    i+=1
if c[1][0]==0 and c[1][1]==0 and c[1][2]:
    i+=1
if c[2][0]==0 and c[2][1]==0 and c[2][2]:
    i+=1
if c[0][0]==0 and c[1][0]==0 and c[2][0]:
    i+=1
if c[0][1]==0 and c[1][1]==0 and c[2][1]:
    i+=1
if c[0][2]==0 and c[1][2]==0 and c[2][2]:
    i+=1
if c[0][0]==0 and c[1][1]==0 and c[2][2]:
    i+=1
if c[0][2]==0 and c[1][1]==0 and c[2][0]:
    i+=1
    
if i>0:
    print("Yes")
elif i==0:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
N=int(input())
# if N>6:
#     print("Yes")
#     exit()
bing=[]
for i in range(N):
    a=list(map(int,stdin.readline().rstrip().split()))[0]
    for i in range(3):
        for j in range(3):
            if data[i][j] not in bing:
                if data[i][j]==a:bing.append([i,j])
if len(bing)<3:
    print("No")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][0]==bing[i+1][0]:count+=1
if count>=3:
    print("Yes")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][1]==bing[i+1][1]:count+=1
if count>=3:
    print("Yes")
    exit()
if [0,0] in bing and [1,1] in bing and [2,2] in bing:
    print("Yes")
    exit()
if [2,0] in bing and [1,1] in bing and [0,2] in bing:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
N=int(input())
# if N>6:
#     print("Yes")
#     exit()
bing=[]
for i in range(N):
    a=list(map(int,stdin.readline().rstrip().split()))[0]
    for i in range(3):
        for j in range(3):
            if data[i][j]==a:bing.append([i,j])
if len(bing)<3:
    print("No")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][0]==bing[i+1][0]:count+=1
if count>=3:
    print("Yes")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][1]==bing[i+1][1]:count+=1
if count>=3:
    print("Yes")
    exit()
if [0,0] in bing and [1,1] in bing and [2,2] in bing:
    print("Yes")
    exit()
if [2,0] in bing and [1,1] in bing and [0,2] in bing:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
N=int(input())
if N>6:
    print("Yes")
    exit()
bing=[]
for i in range(N):
    a=list(map(int,stdin.readline().rstrip().split()))[0]
    for i in range(3):
        for j in range(3):
            if data[i][j]==a:bing.append([i,j])
if len(bing)<3:
    print("No")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][0]==bing[i+1][0]:count+=1
if count>=3:
    print("Yes")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][1]==bing[i+1][1]:count+=1
if count>=3:
    print("Yes")
    exit()
if [0,0] in bing and [1,1] in bing and [2,2] in bing:
    print("Yes")
    exit()
if [2,0] in bing and [1,1] in bing and [0,2] in bing:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    A = [a,b,c]
    n = int(input())
    B = []
    C = []
    for i in range(n):
        B.append(int(input()))
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                C.append(i*10 + j)
    if 0 and 1 and 2 in C:
        print("Yes")
    elif 10 and 11 and 12 in C:
        print("Yes")
    elif 20 and 21 and 22 in C:
        print("Yes")
    elif 0 and 10 and 20 in C:
        print("Yes")
    elif 1 and 11 and 21 in C:
        print("Yes")
    elif 2 and 12 and 22 in C:
        print("Yes")
    elif 0 and 11 and 22 in C:
        print("Yes")
    elif 2 and 11 and 20 in C:
        print("Yes")
    else:
        print("No")
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    A = [a,b,c]
    n = int(input())
    B = []
    C = []
    for i in range(n):
        B.append(int(input()))
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                C.append(i*10 + j)
    if 0 and 1 and 2 in C:
        print("Yes")
    elif 10 and 11 and 12 in C:
        print("Yes")
    elif 20 and 21 and 22 in C:
        print("Yes")
    elif 0 and 10 and 20 in C:
        print("Yes")
    elif 1 and 11 and 21 in C:
        print("Yes")
    elif 2 and 12 and 22 in C:
        print("Yes")
    elif 0 and 11 and 22 in C:
        print("Yes")
    else:
        print("No")
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    A = [a,b,c]
    n = int(input())
    B = []
    C = []
    for i in range(n):
        B.append(int(input()))
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                C.append(i*10 + j)
    if 0 and 1 and 2 in C:
        print("Yes")
    elif 10 and 11 and 12 in C:
        print("Yes")
    elif 20 and 21 and 22 in C:
        print("Yes")
    elif 0 and 10 and 20 in C:
        print("Yes")
    elif 1 and 11 and 21 in C:
        print("Yes")
    elif 2 and 12 and 22 in C:
        print("Yes")
    elif 0 and 11 and 22 in C:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
N=int(input())
if N>6:
    print("Yes")
    exit()
bing=[]
for i in range(N):
    a=list(map(int,stdin.readline().rstrip().split()))[0]
    for i in range(3):
        for j in range(3):
            if data[i][j]==a:bing.append([i,j])
if len(bing)<3:
    print("No")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][0]!=bing[i+1][0]:count+=1
if count>=3:
    print("Yes")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][1]!=bing[i+1][1]:count+=1
if count>=3:
    print("Yes")
    exit()
if [0,0] in bing and [1,1] in bing and [2,2] in bing:
    print("Yes")
    exit()
if [2,0] in bing and [1,1] in bing and [0,2] in bing:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
N=int(input())
# if N>=6:
#     print("Yes")
#     exit()
bing=[]
for i in range(N):
    a=list(map(int,stdin.readline().rstrip().split()))[0]
    for i in range(3):
        for j in range(3):
            if data[i][j]==a:bing.append([i,j])
if len(bing)<3:
    print("No")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][0]!=bing[i+1][0]:count+=1
if count>=3:
    print("Yes")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][1]!=bing[i+1][1]:count+=1
if count>=3:
    print("Yes")
    exit()
if [0,0] in bing and [1,1] in bing and [2,2] in bing:
    print("Yes")
    exit()
if [2,0] in bing and [1,1] in bing and [0,2] in bing:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
N=int(input())
if N>=6:
    print("Yes")
    exit()
bing=[]
for i in range(N):
    a=list(map(int,stdin.readline().rstrip().split()))[0]
    for i in range(3):
        for j in range(3):
            if data[i][j]==a:bing.append([i,j])
if len(bing)<3:
    print("No")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][0]!=bing[i+1][0]:count+=1
if count>=3:
    print("Yes")
    exit()
count=0
for i in range(len(bing)-1):
    if bing[i][1]!=bing[i+1][1]:count+=1
if count>=3:
    print("Yes")
    exit()
if [0,0] in bing and [1,1] in bing and [2,2] in bing:
    print("Yes")
    exit()
if [2,0] in bing and [1,1] in bing and [0,2] in bing:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
data=[list(map(int,stdin.readline().rstrip().split())) for _ in range(3)]
N=int(input())
if N>=6:
    print("Yes")
    exit()
bing=[]
for i in range(N):
    a=list(map(int,stdin.readline().rstrip().split()))[0]
    for i in range(3):
        for j in range(3):
            if data[i][j]==a:bing.append([i,j])
if len(bing)<3:
    print("No")
    exit()
flag=True
for i in range(len(bing)-1):
    if bing[i][0]!=bing[i+1][0]:flag=False
if flag==True:
    print("Yes")
    exit()
flag=True
for i in range(len(bing)-1):
    if bing[i][1]!=bing[i+1][1]:flag=False
if flag==True:
    print("Yes")
    exit()
if [0,0] in bing and [1,1] in bing and [2,2] in bing:
    print("Yes")
    exit()
if [2,0] in bing and [1,1] in bing and [0,2] in bing:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

Solution code:

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

mark = []
for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark.append((j,k))



if ( ((0,0) and (1,1) and (2,2)) or ((0,2) and (1,1) and (2,0)) ) in mark:
    print("Yes")
    exit()
else:
    for i in range(3):
        if ((i,0) and (i,1) and (i,2)) in mark:
            print('Yes')
            exit()
        if ((0,i) and (1,i) and (2,i)) in mark:
            print("Yes")
            exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys
a=[]
for i in range(3):
  a1,a2,a3=map(int,input().split())
  a.append([a1,a2,a3])
  
check=[[0]*3 for i in range(3)]
n=int(input())
b=[]
for i in range(n):
  b.append(int(input()))
for i in b:
  for j in range(3):
    if i in a[j]:
      check[j][a[j].index(i)]=1

naname=[0]*3

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

for j in range(3):
  num=0
  for i in range(3):
    if check[i][j]==1:
      num+=1
      if num==3:
        print('Yes')
        sys.exit()
        
if check[0][0]==check[1][1]==check[2][2]==1:
  print('Yes')
  sys.exit()
if check[0][2]==check[1][1]==check[2][0]==1:
  print('Yes')
  sys.exit()
  
print('No')

Submission status: Wrong Answer

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

mark = []
for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark.append((j,k))


if (((0,0) and (0,1) and (0,2)) or ((1,0) and (1,1) and (1,2)) or ((2,0) and (2,1) and (2,2))) in mark:
    print('Yes')
elif (( (0,0) and (1,1) and (2,2) ) or ( (0,2) and (1,1) and (2,0) ) ) in mark:
    print("Yes")
elif (((0,0) and (1,0) and (2,0)) or ((0,1) and (1,1) and (2,1)) or ((0,2) and (1,2) and (2,2))) in mark:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

flag = False
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
        flag = True

if flag == False:
  print('No')
else:
  if a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0:
    print('Yes')
    sys.exit()
  else:
    for i in range(3):
      if a[i][0] == a[i][1] == a[i][2] == 0 or a[0][i] == a[0][i] == a[0][i]:
        print('Yes')
        sys.exit()
  print('No')

Submission status: Wrong Answer

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

def check(A, b):
    # 横
    for i in range(3):
        cand = []
        for j in range(3):
            cand.append(A[i][j])  # 横
            cand.append(A[j][i])  # 縦
        if set(cand) <= b:
            return True

    # 斜め
    if set([A[0][0], A[1][1], A[2][2]]) <= b or set([A[0][2], A[1][1], A[2][0]]) <= b:
        return True

if check(A, b):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
d=[list(map(int,input().split()))for i in range(3)]
row=int(input())
num=[int(input()) for j in range(row)]
bingo=0
for a in range(3):
  if d[0][a] in num and d[1][a] in num and d[2][a] in num:
    bingo=bingo+1
  if d[a][0] in num and d[a][1] in num and d[a][2] in num:
    bingo=bingo+1
if d[1][1] in num and d[2][2] in num and d[0][0] in num:
  bingo=bingo+1
if d[0][1] in num and d[2][2] in num and d[1][0] in num:
  bingo=bingo+1
if bingo>0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
d=[list(map(int,input().split()))for i in range(3)]
row=int(input())
num=[int(input()) for j in range(row)]
bingo=0
for a in range(3):
  if d[0][a] and d[1][a] and d[2][a] in num:
    bingo=bingo+1
  if d[a][0] and d[a][1] and d[a][2] in num:
    bingo=bingo+1
if d[1][1] and d[2][2] and d[0][0] in num:
  bingo=bingo+1
if d[0][1] and d[2][2] and d[1][0] in num:
  bingo=bingo+1
if bingo>0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
d=[list(map(int,input().split()))for i in range(3)]
row=int(input())
num=[int(input()) for j in range(row)]
bingo=0
for a in range(3):
  if d[0][a] and d[1][a] and d[2][a] in num:
    bingo=bingo+1
  if d[a][0] and d[a][1] and d[a][1] in num:
    bingo=bingo+1
if d[1][1] and d[2][2] and d[0][0] in num:
  bingo=bingo+1
if d[0][1] and d[2][2] and d[1][0] in num:
  bingo=bingo+1
if bingo>0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a=[[0]*3 for i in range(3)]
b=[]
for i in range(3):
  x=input().split()
  a[i][0]=x[0]
  a[i][1]=x[1]
  a[i][2]=x[2]
n=int(input())
for i in range(n):
  b.append(input())
for i in range(n):
  for j in range(9):
    if b[i]==a[j//3][j%3]:
      a[j//3][j%3]='X'
jud=[0,0,0,0]
z=0
res=0
for i in range(3):
  for j in range(2):
    if a[i][j]==a[i][j+1]:
      jud[0]+=1
    if a[j][i]==a[j+1][i]:
      jud[1]+=1
  if max(jud)>1:
    res-=1
  else:
    jud[0]=0
    jud[1]=0
for j in range(2):
  if a[j][j]==a[j+1][j+1]:
    jud[2]+=1
  if a[j][2-j]==a[j+1][2-j-1]:
    jud[3]+=1
  if max(jud)>1:
    res-=1
  else:
    jud[3]=0
    jud[2]=0
if res<0:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a=[[0]*3 for i in range(3)]
b=[]
for i in range(3):
  x=input().split()
  a[i][0]=x[0]
  a[i][1]=x[1]
  a[i][2]=x[2]
n=int(input())
for i in range(n):
  b.append(input())
for i in range(n):
  for j in range(9):
    if b[i]==a[j//3][j%3]:
      a[j//3][j%3]='X'
jud=[0,0,0,0]
z=0
res=0
for i in range(3):
  for j in range(2):
    if a[i][j]==a[i][j+1]:
      jud[0]+=1
    if a[j][i]==a[j+1][i]:
      jud[1]+=1
  if max(jud)>1:
    res-=1
for j in range(2):
  if a[j][j]==a[j+1][j+1]:
    jud[2]+=1
  if a[j][2-j]==a[j+1][2-j-1]:
    jud[3]+=1
  if max(jud)>1:
    res-=1
if res<0:
  print('Yes')
else:
  print('No')