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: Accepted

Solution code:
bingo1 = list(input().split())
bingo2 = list(input().split())
bingo3 = list(input().split())


for i in range(3):
    bingo1[i] = int(bingo1[i])
    bingo2[i] = int(bingo2[i])
    bingo3[i] = int(bingo3[i])
n = int(input())

atari = []
for i in range(n):
    a = int(input())
    atari.append(a)

if bingo1[0] in atari:
    bingo1[0] = 'y'
if bingo1[1] in atari:
    bingo1[1] = 'y'
if bingo1[2] in atari:
    bingo1[2] = 'y'
if bingo2[0] in atari:
    bingo2[0] = 'y'
if bingo2[1] in atari:
    bingo2[1] = 'y'
if bingo2[2] in atari:
    bingo2[2] = 'y'
if bingo3[0] in atari:
    bingo3[0] = 'y'
if bingo3[1] in atari:
    bingo3[1] = 'y'
if bingo3[2] in atari:
    bingo3[2] = 'y'

if bingo1[0] == bingo2[0] == bingo3[0] == 'y':
    print('Yes')
elif bingo1[1] == bingo2[1] == bingo3[1] == 'y':
    print('Yes')
elif bingo1[2] == bingo2[2] == bingo3[2] == 'y':
    print('Yes')

elif bingo1[0] == bingo1[1] == bingo1[2] == 'y':
    print('Yes')
elif bingo2[0] == bingo2[1] == bingo2[2] == 'y':
    print('Yes')
elif bingo3[0] == bingo3[1] == bingo3[2] == 'y':
    print('Yes')

elif bingo1[0] == bingo2[1] == bingo3[2] == 'y':
    print('Yes')
elif bingo1[2] == bingo2[1] == bingo3[0] == 'y':
    print('Yes')

else:
    print('No')

Submission status: Accepted

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


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

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

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

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

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


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

Submission status: Accepted

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()))
flag = False
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        #print('Yes')
        #quit()
        flag = True
for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        #print('Yes')
        #quit()
        flag = True
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    #print('Yes')
    #quit()
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    #print('Yes')
    #quit()
    flag = True
#print('No')
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
bit_ary = [1, 2, 4, 8, 16, 32, 64, 128, 256]
check_ary = [7, 56, 448, 73, 146, 292, 273, 84]
map_ = []
selecter = range(9)
player = 0

def checker(p):
    for check in check_ary:
        if ((check & p) == check):
            return True
    return False

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

    
n = int(input())
for _ in range(n):
    b = int(input())
    try:
        player += bit_ary[map_.index(b)]
        map_[map_.index(b)] = 'done'
    except:
        pass

if checker(player):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
list1=[0]*3
list2=[0]*3
list3=[0]*3
list4=[0]*3
c=0
for i in range(3):
    list1[i], list2[i],  list3[i]= map(int, input().split())
n=int(input())
for j in range(n):
    b=int(input())
    if b in list1:
        list1[list1.index(b)]=0
    if b in list2:
        list2[list2.index(b)]=0
    if b in list3:
        list3[list3.index(b)]=0
for i in range(3):
    list4[i]=list1[i]+list2[i]+list3[i]
d=list1[0]+list2[1]+list3[2]
e=list1[2]+list2[1]+list3[0]
if sum(list1)==0 or sum(list2)==0 or sum(list3)==0 or d==0 or e==0 or(0 in list4):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = []
b = []
flag = 0
a0 = list(map(int, input().split()))
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a.append(a0)
a.append(a1)
a.append(a2)
n = int(input())
for i in range(n):
    b.append(int(input()))
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                a[j][k] = 0

for i in range(3):
    if((a[i][0] + a[i][1] + a[i][2]) == 0):
        flag = 1
    elif((a[0][i] + a[1][i] + a[2][i]) == 0):
        flag =2
    elif((a[0][0] + a[1][1] + a[2][2]) == 0):
        flag = 3
    elif((a[0][2] + a[1][1] + a[2][0]) == 0):
        flag = 4

if(flag != 0):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

for i in range(3):
    if ((bingo[i-1] in b_list) and (bingo[i+2] in b_list) and (bingo[i+5] in b_list)):
        print("Yes")
        exit()

    elif ((bingo[3*(i-1)] in b_list) and (bingo[3*(i-1)+1] in b_list) and (bingo[3*(i-1)+2] in b_list)):
        print("Yes")
        exit()

if ((bingo[0] in b_list) and (bingo[4] in b_list) and (bingo[8] in b_list)):
    print("Yes")
    exit()

elif ((bingo[2] in b_list) and (bingo[4] in b_list) and (bingo[6] in b_list)):
    print("Yes")
    exit()

else:
    print("No")

Submission status: Accepted

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

def solve(lines):
    bingo = []
    for i in range(3):
        bingo.append(list(map(int, lines.pop(0).split(' '))))
    bingo = sum(bingo, [])
    N = int(lines.pop(0))
    for i in range(N):
        a = int(lines.pop(0))
        if a in bingo:
            b = bingo.index(a)
            bingo[b] = -1
    atari = [
        [0,1,2],
        [3,4,5],
        [6,7,8],
        [0,3,6],
        [1,4,7],
        [2,5,8],
        [0,4,8],
        [2,4,6]
    ]

    for ax in atari:
        ok = True
        for i in ax:
            if not bingo[i] < 0:
                ok = False
                continue
        if ok:
            print('Yes')
            return
    print('No')


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

#
# solve !!
#
solve(lines)

Submission status: Accepted

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


fl = 0
for b in range(N):
  for i in range(3):
    for j in range(3):
      if A[i][j] == B[b]:
        A[i][j] = -1
        
for i in range(3):
  if A[i] == [-1,-1,-1]:
    fl = 1
    
for i in range(3):
    if int(A[0][i])*int(A[1][i])*int(A[2][i]) == -1:
      fl = 1

if int(A[0][0])*int(A[1][1])*int(A[2][2]) == -1 or int(A[0][2])*int(A[1][1])*int(A[2][0]) == -1:
  fl = 1

if fl == 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
A = [None] * 9

A[0], A[1], A[2] = map(int, input().split(' '))
A[3], A[4], A[5] = map(int, input().split(' '))
A[6], A[7], A[8] = map(int, input().split(' '))

# print(A)

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

ANS = [None] * 9
# print(ANS)


def main():

    for i in range(N):
        # print('i', i)
        choice = int(input())
        # print('choice:', choice)

        if choice in A:
            ANS[A.index(choice)] = 1


    # print('hitted ans:', ANS)

    if (ANS[0] == 1 and ANS[1] == 1 and ANS[2] == 1) or (ANS[3] == 1 and ANS[4] == 1 and ANS[5] == 1) or (
            ANS[6] == 1 and ANS[7] == 1 and ANS[8] == 1) or (ANS[0] == 1 and ANS[3] == 1 and ANS[6] == 1) or (
            ANS[1] == 1 and ANS[4] == 1 and ANS[7] == 1) or (ANS[2] == 1 and ANS[5] == 1 and ANS[8] == 1) or (
            ANS[0] == 1 and ANS[4] == 1 and ANS[8] == 1) or (ANS[2] == 1 and ANS[4] == 1 and ANS[6] == 1):
        return 'Yes'
    else:
        return 'No'


print(main())

Submission status: Accepted

Solution code:
import sys
N = 3

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
A = []
for _ in range(3):
    A.extend(input().rstrip().split(' '))
n = int(input())
lst = [input() for _ in range(n)]

C = [0 for i in range(9)]

for s in lst:
    for t in range(9):
        if s == A[t]:
            C[t] = 1
Ans = 'No'
Cset = max(C[0] + C[1] + C[2], C[3] + C[4] + C[5], C[6] + C[7] + C[8],C[0] + C[3] + C[6], C[1] + C[4] + C[7], C[2] + C[5] + C[8], C[0] + C[4] + C[8], C[2] + C[4] + C[6])
if Cset == 3:
  Ans = 'Yes'
print(Ans)

Submission status: Accepted

Solution code:
def findnum(b):
    for i in range(len(Aone)):
        if(Aone[i] == b):
            Aone[i] = 0
    for i in range(len(Atwo)):
        if(Atwo[i] == b):
            Atwo[i] = 0
    for i in range(len(Athree)):
        if(Athree[i] == b):
            Athree[i] = 0

Aone = [int(a) for a in input().split()]
Atwo = [int(a) for a in input().split()]
Athree = [int(a) for a in input().split()]
N = int(input())

for i in range(N):
    b = int(input())
    findnum(b)

if(sum(Aone)*sum(Atwo)*sum(Athree)==0):
    print("Yes")
    exit()
for i in range(3):
    if(Aone[i]+Atwo[i]+Athree[i] == 0):
        print("Yes")
        exit()
if((Aone[0]+Atwo[1]+Athree[2])*(Aone[2]+Atwo[1]+Athree[0]) == 0):
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
A = [[0 for i in range(3)] for i in range(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 for i in range(9)]

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

    for a in range(3):
        for aa in range(3):
            tmp = A[a][aa]
            
            if (b_in == tmp):
                index = 3 * a + aa
                b[index] += 1

b_judge = []
b_judge.append(sum(b[0:3]))
b_judge.append(sum(b[3:6]))
b_judge.append(sum(b[6:9]))
b_judge.append(b[0] + b[3] + b[6])
b_judge.append(b[1] + b[4] + b[7])
b_judge.append(b[2] + b[5] + b[8])
b_judge.append(b[0] + b[4] + b[8])
b_judge.append(b[2] + b[4] + b[6])

if (3 in b_judge):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = [input().split() for l in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
ans = 'No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      a[i][j] = int(a[i][j])
      if a[i][j] == b[k]:
        a[i][j] = 1
if a[0][0] * a[0][1] * a[0][2] == 1:
  ans = 'Yes'
if a[1][0] * a[1][1] * a[1][2] == 1:
  ans = 'Yes'
if a[2][0] * a[2][1] * a[2][2] == 1:
	ans = 'Yes'
if a[0][0] * a[1][0] * a[2][0] == 1:
  ans = 'Yes'
if a[0][1] * a[1][1] * a[2][1] == 1:
  ans = 'Yes'
if a[0][2] * a[1][2] * a[2][2] == 1:
  ans = 'Yes'
if a[0][0] * a[1][1] * a[2][2] == 1:
  ans = 'Yes'
if a[2][0] * a[1][1] * a[0][2] == 1:
  ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
A = [[],[],[]]
b = []

for i in range(0,3):
    A[i] = [int(x) for x in input().split(" ")]
N = int(input())
for i in range(0,N):
  b.append(int(input()))

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

if A[0] == [0,0,0] or A[1] == [0,0,0] or A[2] == [0,0,0]:
  print("Yes")
elif [A[0][0],A[1][0],A[2][0]] == [0,0,0]:
  print("Yes")
elif [A[0][1],A[1][1],A[2][1]] == [0,0,0]:
  print("Yes")
elif [A[0][2],A[1][2],A[2][2]] == [0,0,0]:
  print("Yes")
elif [A[0][0],A[1][1],A[2][2]] == [0,0,0]:
  print("Yes")
elif [A[2][0],A[1][1],A[0][2]] == [0,0,0]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
    
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Submission status: Accepted

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

row1=input().split()
row2=input().split()
row3=input().split()

for i in range(3):
  card[0].append(row1[i])
for i in range(3):
  card[1].append(row2[i])
for i in range(3):
  card[2].append(row3[i])
  
n = int(input())
b=[]
bingo = [[],[],[]]
for i in range(3):
  for j in range(3):
    bingo[i].append(None)
for k in range(n):
  t = input()
  b.append(t)
  for i in range(3):
    for j in range(3):
      if t == card[i][j]:
        bingo[i][j] = True
  
flag = "No"
if bingo[0][0] and bingo[1][0] and bingo[2][0]:
  flag = "Yes"
if bingo[0][1] and bingo[1][1] and bingo[2][1]:
  flag = "Yes"
if bingo[0][2] and bingo[1][2] and bingo[2][2]:
  flag = "Yes"
  
if bingo[0][0] and bingo[0][1] and bingo[0][2]:
  flag = "Yes"
if bingo[1][0] and bingo[1][1] and bingo[1][2]:
  flag = "Yes"
if bingo[2][0] and bingo[2][1] and bingo[2][2]:
  flag = "Yes"

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

Submission status: Accepted

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

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

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

print('No')

Submission status: Accepted

Solution code:
al = list(list(map(int, input().split())) for _ in range(3))
n = int(input())
bl = list(int(input()) for _ in range(n))

bingo = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
# for b in bl:
#     if al.count(b) != 0:
#         for i in range(3):
#             for j in range(3):
#                 if al[i][j] == b:
#                     bingo[i][j] = 1
#
# print(bingo)

for i in range(3):
    for j in range(3):
        if bl.count(al[i][j]) > 0:
            bingo[i][j] = 1

for b in bingo:
    if b.count(1) == 3:
        print('Yes')
        exit()

# if bingo[0][0] == 1 and bingo[1][0] == 1 and bingo [2][0] == 1:

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

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

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

print('No')

Submission status: Accepted

Solution code:
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
row = int(input())
detame = [int(input()) for i in range(row)]
bingo = 0
if (a1[0]) in detame and (a1[1]) in detame and (a1[2]) in detame:
    bingo=bingo+1
elif (a2[0]) in detame and (a2[1]) in detame and (a2[2]) in detame:
    bingo=bingo+1
elif (a3[0]) in detame and (a3[1]) in detame and (a3[2]) in detame:
    bingo=bingo+1
elif (a1[0]) in detame and (a2[0]) in detame and (a3[0]) in detame:
    bingo=bingo+1
elif (a1[1]) in detame and (a2[1]) in detame and (a3[1]) in detame:
    bingo=bingo+1
elif (a1[2]) in detame and (a2[2]) in detame and (a3[2]) in detame:
    bingo=bingo+1
elif (a1[0]) in detame and (a2[1]) in detame and (a3[2]) in detame:
    bingo=bingo+1
elif (a1[2]) in detame and (a2[1]) in detame and (a3[0]) in detame:
    bingo=bingo+1
if bingo==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

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

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

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

for i in range(3):
   x = 0
   for j in range(3):
      x += a[j][i]
   if (x == 0):
      print('Yes')
      sys.exit()

tmp = [sum(a[i]) for i in range(3)]
if (min(tmp) == 0):
   print('Yes')
elif (a[0][0] + a[1][1] + a[2][2] == 0):
   print('Yes')
elif (a[0][2] + a[1][1] + a[2][0] == 0):
   print('Yes')
else:
   print('No')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
 
def main():
    bingo_map = [[0] * 3 for _ in range(3)]
    number_list = []
    for _ in range(3):
        A, B, C = map(int, input().split())
        number_list.append(A)
        number_list.append(B)
        number_list.append(C)
    N = int(input())
    for _ in range(N):
        b = int(input())
        if b in number_list:
            pos = number_list.index(b)
            bingo_map[pos//3][pos%3] = 1
        else:
            continue
    nagomi = bingo_map[0][0] + bingo_map[1][1] + bingo_map[2][2]
    kugoi  = bingo_map[0][2] + bingo_map[1][1] + bingo_map[2][0]
    nahaku = bingo_map[0][0] + bingo_map[0][1] + bingo_map[0][2]
    shigoro = bingo_map[1][0] + bingo_map[1][1] + bingo_map[1][2]
    hifumi = bingo_map[2][0] + bingo_map[2][1] + bingo_map[2][2]
    nashii = bingo_map[0][0] + bingo_map[1][0] + bingo_map[2][0]
    yagoni = bingo_map[0][1] + bingo_map[1][1] + bingo_map[2][1]
    kuromi = bingo_map[0][2] + bingo_map[1][2] + bingo_map[2][2]
    if nagomi == 3 or kugoi == 3 or nahaku == 3 or shigoro == 3 or hifumi == 3 or nashii == 3 or yagoni == 3 or kuromi == 3:
        print("Yes")
    else:
        print("No")
 
 
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
ans = 'No'
A = []
for _ in range(3):
    A.append([int(n) for n in input().split()])
N = int(input())
B = []
for i in range(N):
    B.append(int(input()))
for n in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == n:
                A[i][j] = 0
for a,b,c in zip(A[0], A[1], A[2]):
    if sum([a,b,c]) == 0:
        ans = 'Yes'
for i in range(3):
    if sum(A[i]) == 0:
        ans = 'Yes'
if sum([A[0][0], A[1][1], A[2][2]]) == 0:
    ans = 'Yes'
if sum([A[0][2], A[1][1], A[2][0]]) == 0:
    ans = 'Yes'
print(ans)

Submission status: Accepted

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

#よこちぇっく
for i in range(3):  
  if A[i][0] in b:
    if A[i][1] in b:
      if A[i][2] in b:
        flag=True
#たてちぇっく
for j in range(3):  
  if A[0][j] in b:
    if A[1][j] in b:
      if A[2][j] in b:
        flag=True      
#ななめちぇっく1
if A[0][0] in b:
  if A[1][1] in b:
    if A[2][2] in b:
      flag=True
#ななめちぇっく2
if A[0][2] in b:
  if A[1][1] in b:
    if A[2][0] in b:
      flag=True      

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

Submission status: Accepted

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

    check = [[False] * 3 for _ in range(3)]

    for b_one in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == b_one:
                    check[i][j] = True

    if check[0][0] and check[0][1] and check[0][2]:
        print('Yes')
        return
    if check[1][0] and check[1][1] and check[1][2]:
        print('Yes')
        return
    if check[2][0] and check[2][1] and check[2][2]:
        print('Yes')
        return
    if check[0][0] and check[1][0] and check[2][0]:
        print('Yes')
        return
    if check[0][1] and check[1][1] and check[2][1]:
        print('Yes')
        return
    if check[0][2] and check[1][2] and check[2][2]:
        print('Yes')
        return
    if check[0][0] and check[1][1] and check[2][2]:
        print('Yes')
        return
    if check[0][2] and check[1][1] and check[2][0]:
        print('Yes')
        return

    print('No')

resolve()

Submission status: Accepted

Solution code:
a11,a12,a13 = map(int,input().split())
a21,a22,a23 = map(int,input().split())
a31,a32,a33 = map(int,input().split())
n = int(input())
b = [int(input()) for i in range(n)]
a = [a11,a12,a13,a21,a22,a23,a31,a32,a33]
A = []
a.sort()


for i in b:
    if i in a:
        A.append(i)
    else:
        pass
    
if a11 in A and a12 in A and a13 in A:
    print('Yes')
elif a21 in A and a22 in A and a23 in A:
    print('Yes')
elif a31 in A and a32 in A and a33 in A:
    print('Yes')
elif a11 in A and a21 in A and a31 in A:
    print('Yes')
elif a12 in A and a22 in A and a32 in A:
    print('Yes')
elif a13 in A and a23 in A and a33 in A:
    print('Yes')
elif a11 in A and a22 in A and a33 in A:
    print('Yes')
elif a13 in A and a22 in A and a31 in A:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

b1 = [0,0,0]
b2 = [0,0,0]
b3 = [0,0,0]

for i in range(n):
    b = int(input())
    for j in range(3):
        if a1[j] == b:
            b1[j] = 1
        if a2[j] == b:
            b2[j] = 1
        if a3[j] == b:
            b3[j] = 1

if b1[0] == 1 and b1[1] == 1 and b1[2] == 1:
    print("Yes")
elif b2[0] == 1 and b2[1] == 1 and b2[2] == 1:
    print("Yes")
elif b3[0] == 1 and b3[1] == 1 and b3[2] == 1:
    print("Yes")
elif b1[0] == 1 and b2[0] == 1 and b3[0] == 1:
    print("Yes")
elif b1[1] == 1 and b2[1] == 1 and b3[1] == 1:
    print("Yes")
elif b1[2] == 1 and b2[2] == 1 and b3[2] == 1:
    print("Yes")
elif b1[0] == 1 and b2[1] == 1 and b3[2] == 1:
    print("Yes")
elif b1[2] == 1 and b2[1] == 1 and b3[0] == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin,exit
import  numpy as np
A = [stdin.readline().rstrip().split() for _ in range(3)]
A=sum(A,[])
n = int(stdin.readline().rstrip())
B= [stdin.readline().rstrip().split() for _ in range(n)]
B=sum(B,[])
if len(B)<=2:
    print("No")
    sys.exit()
for i in range(len(B)):
    try:
        A[A.index(B[i])]=0
    except:
        continue
A=[int(i) for i in A]
if A[1]+A[2]+A[0]==0 or A[0]+A[3]+A[6]==0 or A[2]+A[4]+A[6]==0 or A[3]+A[4]+A[5]==0 or A[1]+A[4]+A[7]==0 or A[0]+A[4]+A[8]==0 or A[6]+A[7]+A[8]==0 or A[2]+A[5]+A[8]==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
li1 = list(map(int,input().split()))
li1.extend(list(map(int,input().split())))
li1.extend(list(map(int,input().split())))
n = int(input())
for i in range(n):
  p = int(input())
  li1 = [0 if j == p else j for j in li1]
if ( li1[0] + li1[1] + li1[2] ) == 0:
  print('Yes')
elif ( li1[3] + li1[4] + li1[5] ) == 0:
  print('Yes')
elif ( li1[6] + li1[7] + li1[8] ) == 0:
  print('Yes')
elif ( li1[0] + li1[3] + li1[6] ) == 0:
  print('Yes')
elif ( li1[1] + li1[4] + li1[7] ) == 0:
  print('Yes')
elif ( li1[2] + li1[5] + li1[8] ) == 0:
  print('Yes')
elif ( li1[0] + li1[4] + li1[8] ) == 0:
  print('Yes')
elif ( li1[2] + li1[4] + li1[6] ) == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
flatten_A = []

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

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

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

mark_list = [False] * 9

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

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

ans = judge_bingo(mark_list)
print(ans)
# print(A)
# print(flatten_A)
# print(mark_list)

Submission status: Accepted

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

bingo = {
    data[0][0]: False, data[0][1]: False, data[0][2]: False,
    data[1][0]: False, data[1][1]: False, data[1][2]: False,
    data[2][0]: False, data[2][1]: False, data[2][2]: False,
}
n = int(input())

for i in range(0, n):
    number = int(input())
    if number in bingo:
        bingo[number] = True

result = False;
for i in range(0, 3):
    if bingo[data[i][0]] and bingo[data[i][1]] and bingo[data[i][2]]:
        result = True
    if bingo[data[0][i]] and bingo[data[1][i]] and bingo[data[2][i]]:
        result = True

if bingo[data[0][0]] and bingo[data[1][1]] and bingo[data[2][2]]:
    result = True

if bingo[data[0][2]] and bingo[data[1][1]] and bingo[data[2][0]]:
    result = True

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

Submission status: Accepted

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 i in range(N):
    b.append(int(input()))
ans = "No"

if (A1[0] in b) and (A2[0] in b) and (A3[0] in b):
    ans = "Yes"
if (A1[1] in b) and (A2[1] in b) and (A3[1] in b):
    ans = "Yes"
if (A1[2] in b) and (A2[2] in b) and (A3[2] in b):
    ans = "Yes"
if (A1[0] in b) and (A2[1] in b) and (A3[2] in b):
    ans = "Yes"
if (A1[2] in b) and (A2[1] in b) and (A3[0] in b):
    ans = "Yes"
if (A1[0] in b) and (A1[1] in b) and (A1[2] in b):
    ans = "Yes"
if (A2[0] in b) and (A2[1] in b) and (A2[2] in b):
    ans = "Yes"
if (A3[0] in b) and (A3[1] in b) and (A3[2] in b):
    ans = "Yes"

print(ans)

Submission status: Accepted

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 = []
save = []
count = 0
hantei1 = [[1,1],[2,2],[3,3]]
hantei2 = [[1,1],[1,2],[1,3]]
hantei3 = [[2,1],[2,2],[2,3]]
hantei4 = [[3,1],[3,2],[3,3]]
hantei5 = [[1,3],[2,2],[3,1]]
hantei6 = [[1,1],[2,1],[3,1]]
hantei7 = [[1,2],[2,2],[3,2]]
hantei8 = [[1,3],[2,3],[3,3]]
for i in range(N):
    b.append(int(input()))

for i in range(N):
    if b[i] in A_1:
        save.append([1,A_1.index(b[i])+1])
    if b[i] in A_2:
        save.append([2,A_2.index(b[i])+1])
    if b[i] in A_3:
        save.append([3,A_3.index(b[i])+1])


if hantei1[0] in save and hantei1[1] in save and hantei1[2] in save:
    count +=1
if hantei2[0] in save and hantei2[1] in save and hantei2[2] in save:
    count +=1
if hantei3[0] in save and hantei3[1] in save and hantei3[2] in save:
    count +=1
if hantei4[0] in save and hantei4[1] in save and hantei4[2] in save:
    count +=1
if hantei5[0] in save and hantei5[1] in save and hantei5[2] in save:
    count +=1
if hantei6[0] in save and hantei6[1] in save and hantei6[2] in save:
    count +=1
if hantei7[0] in save and hantei7[1] in save and hantei7[2] in save:
    count +=1
if hantei8[0] in save and hantei8[1] in save and hantei8[2] in save:
    count +=1

if count >= 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A_1 = input().split()
A_2 = input().split()
A_3 = input().split()

N = int(input())

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

ans = "No"

if A_1[0] in B_list:
    if A_2[0] in B_list and A_3[0] in B_list:
        ans = "Yes"
    elif A_1[1] in B_list and A_1[2] in B_list:
        ans = "Yes"
    elif A_2[1] in B_list and A_3[2] in B_list:
        ans = "Yes"

if A_1[1] in B_list and A_2[1] in B_list and A_3[1] in B_list:
    ans = "Yes"
elif A_1[2] in B_list and A_2[1] in B_list and A_3[0] in B_list:
    ans = "Yes"
elif A_1[2] in B_list and A_2[2] in B_list and A_3[2] in B_list:
    ans = "Yes"    
elif A_2[0] in B_list and A_2[1] in B_list and A_2[2] in B_list:
    ans = "Yes"
elif A_3[0] in B_list and A_3[1] in B_list and A_3[2] in B_list:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
a11,a12,a13=map(int,input().split())
a21,a22,a23=map(int,input().split())
a31,a32,a33=map(int,input().split())
n=int(input())
l=[]
b=[a11,a12,a13,a21,a22,a23,a31,a32,a33]
for i in range(n):
  m=int(input())
  for j in range(9):
    if m==b[j]:
      b[j]=0
if b[0]==0 and b[1]==0 and b[2]==0:
  print('Yes')
elif b[3]==0 and b[4]==0 and b[5]==0:
  print('Yes')
elif b[6]==0 and b[7]==0 and b[8]==0:
  print('Yes')
elif b[0]==0 and b[3]==0 and b[6]==0:
  print('Yes')
elif b[1]==0 and b[4]==0 and b[7]==0:
  print('Yes')
elif b[2]==0 and b[5]==0 and b[8]==0:
  print('Yes')
elif b[0]==0 and b[4]==0 and b[8]==0:
  print('Yes')
elif b[2]==0 and b[4]==0 and b[6]==0:
  print('Yes')
else:
  print('No')