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:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

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

    N = int(input())
    s = [False for _ in range(9)]
    for i in range(N):
        b = int(input())
        if b in A:
            s[A.index(b)] = True

    bingo = \
        (s[0] and s[1] and s[2]) or \
        (s[3] and s[4] and s[5]) or \
        (s[6] and s[7] and s[8]) or \
        (s[0] and s[3] and s[6]) or \
        (s[1] and s[4] and s[7]) or \
        (s[2] and s[5] and s[8]) or \
        (s[0] and s[4] and s[8]) or \
        (s[2] and s[4] and s[6])

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        flag=1                    
    if a[0][i]==a[1][i]==a[2][i]:
        flag=1
if a[0][0]==a[1][1]==a[2][2] or a[0][2]==a[1][1]==a[2][0]:
    flag=1
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# ビンゴを用意x3行
A = [list(map(int, input().split())) for _ in range(3)]
# N個呼ぶ
N = int(input())

for _ in range(N):
    b = int(input())
    for y in range(3):
        for x in range(3):
            # リストAの数字の10の桁yと1桁xがbと一緒なら-1とする
            if A[y][x] == b:
                A[y][x] = -1
# 10の桁が合っているかの処理
for y in range(3):
    f = True
    for x in range(3):
        # 上の処理で-1がビンゴとして
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()
# 1の桁が合っているかの処理
for x in range(3):
    f = True
    for y in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

f = True
for x in range(3):
    if A[x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

f = True
for x in range(3):
    if A[2 - x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

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

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

    for i in range(3):
        if (A[i][0] + A[i][1] + A[i][2] == 0):
            print('Yes')
            return
        if (A[0][i] + A[1][i] + A[2][i] == 0):
            print('Yes')
            return
        if (A[0][0] + A[1][1] + A[2][2] == 0):
            print('Yes')
            return
        if (A[0][2] + A[1][1] + A[2][0] == 0):
            print('Yes')
            return

    print("No")

    return
resolve()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    As = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    Bs = [int(input()) for _ in range(n)]
    
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if Bs[i] == As[j][k]:
                    As[j][k] = 0
                    if (k in [0,2] and j in [0,2]) or (j == 1 and k == 1):
                        if (As[0][0] == 0 and As[1][1]  == 0 and As[2][2] == 0) or (As[0][2] == 0 and As[1][1]  == 0 and As[2][0] == 0):
                            print('Yes')
                            return
                    if (As[j][0] == 0 and As[j][1] == 0 and As[j][2] == 0) or (As[0][k] == 0 and As[1][k] == 0 and As[2][k] == 0):
                        print('Yes')
                        return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

c = 0
for i in range(3):
    if a[0][i] in b and a[1][i] in b and a[2][i] in b:
        print("Yes")
        c = 1
        break
    if a[i][0] in b and a[i][1] in b and a[i][2] in b:
        print("Yes")
        c = 1
        break
if a[1][1] in b:
    if a[0][0] in b and a[2][2]in b and c==0:
        print("Yes")
        c = 1
    if a[0][2] in b and a[2][0]in b and c==0:
        print("Yes")
        c = 1 
if c == 0:
    print("No")

Submission status: Accepted

Solution code:
import itertools
A = list(itertools.chain.from_iterable([list(map(int, input().split())) for _ in range(3)]))

bingo = [0 for _ in range(10)]
N = int(input())

for i in range(N):
    b = int(input())
    for j in range(9):
        if b == A[j]:
            bingo[j] = 1

f = 0
for i in range(3):
    if sum(bingo[i*3:i*3+3]) == 3:
        f = 1
        break
    if sum(bingo[i::3]) == 3:
        f = 1
        break

if sum(bingo[0::4]) == 3:
    f = 1
if sum(bingo[2:7:2]) == 3:
    f = 1

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

'''
1 2 3
4 5 6 
7 8 9
3
1
4
7
'''

Submission status: Accepted

Solution code:
import sys
import numpy as np

readline = sys.stdin.buffer.readline
a = np.array([])
for _ in range(3):
  a = np.append(a,list(map(int, readline().split())))
n = int(readline())

a = a.reshape(3,3)
a_2 = np.append(a,np.diag(a))
a_2 = np.append(a_2,[a[0][2],a[1][1],a[2][0]])

a_2 = a_2.reshape(5,3)
for _ in range(n):
  temp=int(readline())
  a[a==temp]=0
  a_2[a_2==temp]=0

print('Yes' if 0 in np.sum(a_2, axis=1) or 0 in np.sum(a, axis=0) else 'No')

Submission status: Accepted

Solution code:
A=[]
k=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(3):
  A.append(list(map(int,input().split())))
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    for l in range(3):
      if A[j][l]==b:
        k[j][l]=1

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

Submission status: Accepted

Solution code:
import sys
L = list(list(map(int,input().split())) for i in range(3))
n = int(input())
ls = [int(input()) for j in range(n)]
lsls = [0]
lsls[0] = L[0] + L[1] + L[2]
for k in range(n):
    for l in range(9):
        if ls[k] == lsls[0][l]:
            lsls[0][l] = 0
for r in range(3):
    b = [e for e in lsls[0]]
    a = b[r::3]
    if (sum(b[0:3]) ==0) or (sum(b[3:6]) ==0) or(sum(b[6:9]) ==0) or(sum(a) ==0):
        print("Yes")
        sys.exit()
if (lsls[0][0]+lsls[0][4]+lsls[0][8] == 0) or (lsls[0][2]+lsls[0][4]+lsls[0][6] == 0):
    print("Yes")
    sys.exit()
print("No")

Submission status: Accepted

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

n = int(input())

for j in range(n):
    b = int(input())
    for k in range(9):
        if a[k] == b:
            a[k] = 0
        
if a[0] == 0 and a[1] == 0 and a[2] == 0:
    print('Yes')
elif a[3] == 0 and a[4] == 0 and a[5] == 0:
    print('Yes')
elif a[6] == 0 and a[7] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[3] == 0 and a[6] == 0:
    print('Yes')
elif a[1] == 0 and a[4] == 0 and a[7] == 0:
    print('Yes')
elif a[2] == 0 and a[5] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[4] == 0 and a[8] == 0:
    print('Yes')
elif a[2] == 0 and a[4] == 0 and a[6] == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A1 = input().split()
A2 = input().split()
A3 = input().split()
n = int(input())
B = []
for _ in range(n):
    B.append(input())
C1 = []
C2 = []
C3 = []
for Ae in A1:
    if Ae in B:
        C1.append('t')
    else:
        C1.append('f')
for Ae in A2:
    if Ae in B:
        C2.append('t')
    else:
        C2.append('f')
for Ae in A3:
    if Ae in B:
        C3.append('t')
    else:
        C3.append('f')
# print(C1)
# print(C2)
# print(C3)
D1 = [C1[0], C2[0], C3[0]]
D2 = [C1[1], C2[1], C3[1]]
D3 = [C1[2], C2[2], C3[2]]
E1 = [C1[0], C2[1], C3[2]]
E2 = [C1[2], C2[1], C3[0]]
# print(D1)
if 'f' not in C1 or 'f' not in C2 or 'f' not in C3:
    print('Yes')
    exit()
if 'f' not in D1 or 'f' not in D2 or 'f' not in D3:
    print('Yes')
    exit()
if 'f' not in E1 or 'f' not in E2:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

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

    N = int(input())

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

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

    for i in range(N):
        b = int(input())
        for j in range(3):
            for k in range(3):
                if b == a[j][k]:
                    result[j][k] = True

    ans = "No"

    for i in range(3):
        if result[i][0] and result[i][1] and result[i][2] is True:
            ans = "Yes"

    for i in range(3):
        if result[0][i] and result[1][i] and result[2][i] is True:
            ans = "Yes"

    if result[0][0] and result[1][1] and result[2][2] is True:
        ans = "Yes"

    if result[2][0] and result[1][1] and result[0][2] is True:
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A = [0]*3
nums = set([])
for i in range(3):
    A[i] = list(map(int,input().split()))
    for j in A[i]:
        nums.add(j)
N = int(input())

for i in range(N):
    b = int(input())
    if b in nums:
        for i in range(3):
            try:
                ind = A[i].index(b)
                A[i][ind] = 0
            except ValueError:
                continue

ans = 0
for i in range(3):#行ベクトル
    if sum(A[i]) == 0:
        ans += 1

for j in range(3):#列ベクトル
    tmp = 0
    for k in range(3):
        tmp += A[k][j]
    if tmp == 0:
        ans += 1

tmp = 0
tmp2 = 0
for m in range(3):
    tmp += A[m][m]
    tmp2 += A[m][-m-1]
if tmp == 0:
    ans += 1
if tmp2 == 0:
    ans += 1

if ans > 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()


    
a = [[0]*3 for i in range(3)]
for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
b = [0]*n
bingo = "No"
for i in range(n):
    b[i] = int(input())
    for k in range(3):
        if a[k][0] == b[i]:
            a[k][0] = 0
        if a[k][1] == b[i]:
            a[k][1] = 0
        if a[k][2] == b[i]:
            a[k][2] = 0
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0:
        bingo = "Yes"
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i] == 0:
        bingo = "Yes"
if a[0][0]+a[1][1]+a[2][2] == 0:
    bingo = "Yes"
if a[2][0]+a[1][1]+a[0][2] == 0:
    bingo = "Yes"
 
print(bingo)

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    
    a = [[0]*3 for i in range(3)]
    for i in range(3):
        a[i] = list(map(int, input().split()))
    n = int(input())
    b = [0]*n
    bingo = "No"
    for i in range(n):
        b[i] = int(input())
        for k in range(3):
            if a[k][0] == b[i]:
                a[k][0] = 0
            if a[k][1] == b[i]:
                a[k][1] = 0
            if a[k][2] == b[i]:
                a[k][2] = 0
    for i in range(3):
        if a[i][0]+a[i][1]+a[i][2] == 0:
            bingo = "Yes"
    for i in range(3):
        if a[0][i]+a[1][i]+a[2][i] == 0:
            bingo = "Yes"
    if a[0][0]+a[1][1]+a[2][2] == 0:
        bingo = "Yes"
    if a[2][0]+a[1][1]+a[0][2] == 0:
        bingo = "Yes"
     
    print(bingo)
main()

Submission status: Accepted

Solution code:
A = []
ans = 'No'
for i in range(3):
    A.append(list(map(int,input().split())))
n = int(input())
b = 0
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
for i in range(3):
    if A[i][0]+A[i][1]+A[i][2] == 0 or A[0][i]+A[1][i]+A[2][i] == 0 or A[0][0]+A[1][1]+A[2][2] == 0 or A[0][2]+A[1][1]+A[2][0] == 0:
            ans ='Yes'
print(ans)

Submission status: Accepted

Solution code:
card = [list(map(int,list(input().split()))) for i in range(3)]
n = n=int(input())
s=[int(input()) for i in range(n)]
ans = "No"

for i in card:
    for j in i:
        if j in s:
            location = i.index(j)
            i[location] = -1

if card[0][0] == card[1][0] == card[2][0] == -1 or card[0][1] == card[1][1]== card[2][1] == -1 or card[0][2] == card[1][2] == card[2][2] == -1:
    ans = "Yes"
    
if card[0] == [-1, -1, -1]:
    ans = "Yes"
if card[1] == [-1, -1, -1]:
    ans = "Yes"
if card[2] == [-1, -1, -1]:
    ans = "Yes"

if card[0][0] == card[1][1] == card[2][2] == -1 or card[0][2] == card[1][1]== card[2][0] == -1:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    A = []
    for _ in range(3):
        A.append(list(map(int, input().split())))
    
    N = int(input())
    for _ in range(N):
        b = int(input())
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    A[i][j] = 0
    
    ans = "No"
    for i in range(3):
        if A[i][0] == A[i][1] and A[i][1] == A[i][2]:
            ans = "Yes"
            break
    for j in range(3):
        if A[0][j] == A[1][j] and A[1][j] == A[2][j]:
            ans = "Yes"
            break
    
    if A[0][0] == A[1][1] and A[1][1] == A[2][2]:
        ans = "Yes"
    if A[0][2] == A[1][1] and A[1][1] == A[2][0]:
        ans = "Yes"

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = [[0]*3 for i in range(3)]
for i in range(3):
    a[i] = list(map(int, input().split()))
n = int(input())
b = [0]*n
bingo = "No"
for i in range(n):
    b[i] = int(input())
    for k in range(3):
        if a[k][0] == b[i]:
            a[k][0] = 0
        if a[k][1] == b[i]:
            a[k][1] = 0
        if a[k][2] == b[i]:
            a[k][2] = 0
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0:
        bingo = "Yes"
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i] == 0:
        bingo = "Yes"
if a[0][0]+a[1][1]+a[2][2] == 0:
    bingo = "Yes"
if a[2][0]+a[1][1]+a[0][2] == 0:
    bingo = "Yes"

print(bingo)

Submission status: Accepted

Solution code:
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
num_of_number = int(input())

numbers = []

for _ in range(num_of_number):
    numbers.append(int(input()))

for number in numbers:
    for i, A in enumerate(A1):
        if A in numbers:
            A1[i] = -1

    for i, A in enumerate(A2):
        if A in numbers:
            A2[i] = -1

    for i, A in enumerate(A3):
        if A in numbers:
            A3[i] = -1

# 横の確認
if A1.count(-1) == 3 or A2.count(-1) == 3 or A3.count(-1) == 3:
    print('Yes')
    exit()

# 縦の確認
V1_count = [A1[0], A2[0], A3[0]].count(-1)
V2_count = [A1[1], A2[1], A3[1]].count(-1)
V3_count = [A1[2], A2[2], A3[2]].count(-1)
if V1_count == 3 or V2_count == 3 or V3_count == 3:
    print('Yes')
    exit()

# 斜めの確認
D1_count = [A1[0], A2[1], A3[2]].count(-1)
D2_count = [A1[2], A2[1], A3[0]].count(-1)
if D1_count == 3 or D2_count == 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    A = [NLI() for _ in range(3)]
    N = NI()
    B = [NI() for _ in range(N)]
    hit = [[0]*3 for _ in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if b == A[i][j]:
                    hit[i][j] = 1

    for h in hit:
        if sum(h) == 3:
            print("Yes")
            exit()
    for j in range(3):
        if hit[0][j] + hit[1][j] + hit[2][j] == 3:
            print("Yes")
            exit()
    if hit[0][2] + hit[1][1] + hit[2][0] == 3:
        print("Yes")
        exit()
    if hit[0][0] + hit[1][1] + hit[2][2] == 3:
        print("Yes")
        exit()
    print("No")



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
square = [input().split(" "), input().split(" "), input().split(" ")]
n = int(input())

for i in range(n):
    num = input()
    for row in square:
        if num in row:
            row[row.index(num)] = 'x'

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

Submission status: Accepted

Solution code:
a = [[0]*3]*3
for i in range(3):
  a[i] = list(map(int,input().split()))
  
def isInList(b,a):
  for i in range(len(a)):
    for j in range(len(a[i])):
      if a[i][j] == b:
        return i,j
      
  return -1,-1
  
N = int(input())
for i in range(N):
  b = int(input())
  I,J = isInList(b,a)
  if I != -1:
    a[I][J] = -1
    

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


ans = "Yes" if judge(a) else "No"
print(ans)

Submission status: Accepted

Solution code:
a = []
for x in range(3):
    a.append(list(map(int, input().split())))
row = [0] * 3
col = [0] * 3
sli = [0] * 2

c = [[False] * 3 for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b:
                c[x][y] = True
flag = False
for i in range(3):
    if c[i].count(True) == 3:
        flag = True
    if c[0][i] == c[1][i] == c[2][i] == True:
        flag = True
if c[0][0] == c[1][1] == c[2][2] == True:
    flag = True
if c[0][2] == c[1][1] == c[2][0] == True:
    flag = True

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

Submission status: Accepted

Solution code:
import numpy as np

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

hit = np.zeros((3, 3))

N = int(input())
b = np.zeros((N, 1))

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

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

hit_T = hit.T

if hit[0][0] + hit[1][1] + hit[2][2] == 3 or \
    hit[0][2] + hit[1][1] + hit[2][0] == 3:
    print('Yes')
    exit()

for i in range(3):
    if sum(hit[i]) == 3:
        print('Yes')
        exit()
    if sum(hit_T[i]) == 3:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

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

tar=[]
for i in range(n):
  ck=int(input())
  for p in range(9):
    if A[p//3][p%3] == ck:
      tar.append(p)
      
def check(a,b,c):
  if a in tar and b in tar and c in tar:
    return 1
  else:
    return 0
  
res=check(0,1,2)+check(3,4,5)+check(6,7,8)+check(0,3,6)+check(1,4,7)+check(2,5,8)+check(0,4,8)+check(2,4,6)
if res == 0:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
a1,a2,a3=map(int,input().split())
b1,b2,b3=map(int,input().split())
c1,c2,c3=map(int,input().split())
l=[[0]*3 for _ in range(3)]
n=int(input())
for _ in range(n):
    b=int(input())
    if a1==b:
        l[0][0]=1
    elif a2==b:
        l[0][1]=1
    elif a3==b:
        l[0][2]=1
    elif b1==b:
        l[1][0]=1
    elif b2==b:
        l[1][1]=1
    elif b3==b:
        l[1][2]=1
    elif c1==b:
        l[2][0]=1
    elif c2==b:
        l[2][1]=1
    elif c3==b:
        l[2][2]=1
if l[0]==[1,1,1] or l[1]==[1,1,1] or l[2]==[1,1,1]:
    print('Yes')
elif l[0][0]==1 and l[1][0]==1 and l[2][0]==1 or l[0][1]==1 and l[1][1]==1 and l[2][1]==1 or l[0][2]==1 and l[1][2]==1 and l[2][2]==1:
    print('Yes')
elif l[0][0]==1 and l[1][1]==1 and l[2][2]==1 or l[0][2]==1 and l[1][1] and l[2][0]==1:
    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 = [int(input()) for i in range(n)]
set(b)

bingo = 0
checker = 0

for i in range(len(b)):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = "o"
        checker += 1

if checker > 0:       
  for l in range(3):
    if a[l].count("o") == 3:
      bingo += 1
    if a[0][l] == a[1][l] == a[2][l] == "o":
      bingo += 1
  if a[0][0] == a[1][1] == a[2][2] == "o":
    bingo += 1
  if a[0][2] == a[1][1] == a[2][0] == "o":
    bingo += 1
    
if bingo > 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
bingo = []
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

N = int(input())

for i in range(N):
    n = int(input())
    if n in a:
        a[a.index(n)] = 0
    elif n in b:
        b[b.index(n)] = 0
    elif n in c:
        c[c.index(n)] = 0

if sum(a) == 0 or sum(b) == 0 or sum(c) == 0 or a[0]+ b[1] + c[2] == 0 or a[2] + b[1] + c[0] == 0 :
    print("Yes")
elif a[0] + b[0]+ c[0] ==0 or a[1] + b[1]+ c[1] == 0 or a[2] + b[2]+ c[2] == 0 :
    print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
A1 = map(int, input().split())
A2 = map(int, input().split())
A3 = map(int, input().split())
N = int(input())
b = [int(input()) for x in range(N)]
A1_check = []
A2_check = []
A3_check = []

for i, item in enumerate(A1):
    if item in b:
        A1_check.append(i+1)

for i, item in enumerate(A2):
    if item in b:
        A2_check.append(i+1)

for i, item in enumerate(A3):
    if item in b:
        A3_check.append(i+1)

if (len(A1_check) == 3 or \
len(A2_check) == 3 or \
len(A3_check) == 3 or \
(1 in A1_check and 1 in A2_check and 1 in A3_check) or \
(2 in A1_check and 2 in A2_check and 2 in A3_check) or \
(3 in A1_check and 3 in A2_check and 3 in A3_check) or \
(1 in A1_check and 2 in A2_check and 3 in A3_check) or \
(3 in A1_check and 2 in A2_check and 1 in A3_check)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b_i = list([int(input()) for _ in range(N)])
ans = "No"

for bi in b_i:
    for i in range(3):
        for j in range(3):
            if A[i][j] == bi:
                A[i][j] = "hole"
# 横
for i in range(3):
    if A[i][0] == "hole":
        if A[i][1] == "hole" and A[i][2] == "hole":
            ans = "Yes"

# 縦
for i in range(3):
    if A[0][i] == "hole":
        if A[1][i] == "hole" and A[2][i] == "hole":
            ans = "Yes"

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

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

print(ans)

Submission status: Accepted

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

for i in range(n):
    for j in range(3):
        if (b[i] in a_list[j]):
            a_list[j][a_list[j].index(b[i])] = 'ok'

yn = 'No'
for i in range(3):
    if a_list[i] == ['ok', 'ok', 'ok']:
        yn = 'Yes'
for i in range(3):
    if a_list[0][i] == 'ok' and a_list[1][i] == 'ok' and a_list[2][i] == 'ok':
        yn = 'Yes'
if a_list[0][0] == 'ok' and a_list[1][1] == 'ok' and a_list[2][2] == 'ok':
    yn = 'Yes'
if a_list[0][2] == 'ok' and a_list[1][1] == 'ok' and a_list[2][0] == 'ok':
    yn = 'Yes'

if yn == 'Yes':
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a=[]
for i in range(3):
  a1,a2,a3=map(int,input().split())
  a.append(a1)
  a.append(a2)
  a.append(a3)
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(9):
    if a[j]==b:
      a[j]=0
if a[0]==0 and a[1]==0 and a[2]==0:
  print("Yes")
elif a[3]==0 and a[4]==0 and a[5]==0:
  print("Yes")
elif a[6]==0 and a[7]==0 and a[8]==0:
  print("Yes")
elif a[0]==0 and a[3]==0 and a[6]==0:
  print("Yes")
elif a[1]==0 and a[4]==0 and a[7]==0:
  print("Yes")
elif a[2]==0 and a[5]==0 and a[8]==0:
  print("Yes")
elif a[0]==0 and a[4]==0 and a[8]==0:
  print("Yes")
elif a[2]==0 and a[4]==0 and a[6]==0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
As=[]
As.append(list(map(int,input().split())))
As.append(list(map(int,input().split())))
As.append(list(map(int,input().split())))
N=int(input())
is_bingo=False
n=0
while n<N:
  n+=1
  b=int(input())
  for i in range(3):
    for j in range(3):
      if As[i][j] == b:
        As[i][j]=0
  for _ in range(1):
    if As[0][0]+As[0][1]+As[0][2]==0:
      is_bingo=True
      break
    if As[1][0]+As[1][1]+As[1][2]==0:
      is_bingo=True
      break
    if As[2][0]+As[2][1]+As[2][2]==0:
      is_bingo=True
      break
    if As[0][0]+As[1][0]+As[2][0]==0:
      is_bingo=True
      break
    if As[0][1]+As[1][1]+As[2][1]==0:
      is_bingo=True
      break
    if As[0][2]+As[1][2]+As[2][2]==0:
      is_bingo=True
      break
    if As[0][0]+As[1][1]+As[2][2]==0:
      is_bingo=True
      break
    if As[2][0]+As[1][1]+As[0][2]==0:
      is_bingo=True
      break

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

Submission status: Accepted

Solution code:
grid = []
for _ in range(3): 
    grid.append(list(map(int, input().split())))
ns = [int(input()) for _ in range(int(input()))]
for i in range(3):
    for j in range(3):
        if grid[i][j] in ns:
            grid[i][j]= True
        else:
            grid[i][j] = False
flg = False
for i in range(3):
    if (grid[0][i] and grid[1][i] and grid[2][i]) or (grid[i][0] and grid[i][1] and grid[i][2]) or (grid[0][0] and grid[1][1] and grid[2][2]) or (grid[0][2] and grid[1][1] and grid[2][0]):
        flg = True
        break
if flg:
    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=[int(input()) for j in range(N)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            A[i][j]=0
for i in range(3):
    if len(set(A[i]))==1:
        print("Yes")
        exit()
    if A[0][i]==A[1][i]==A[2][i]==0:
        print("Yes")
        exit()
if A[0][0]==A[1][1]==A[2][2]==0 or A[0][2]==A[1][1]==A[2][0]==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

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

flg = False
if chk[0][0] and chk[0][1] and chk[0][2]:
	flg = True
if chk[1][0] and chk[1][1] and chk[1][2]:
	flg = True
if chk[2][0] and chk[2][1] and chk[2][2]:
	flg = True
if chk[0][0] and chk[1][0] and chk[2][0]:
	flg = True
if chk[0][1] and chk[1][1] and chk[2][2]:
	flg = True
if chk[0][2] and chk[1][2] and chk[2][2]:
	flg = True
if chk[0][0] and chk[1][1] and chk[2][2]:
	flg = True
if chk[0][2] and chk[1][1] and chk[2][0]:
	flg = True

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

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for c in range(3):
        for r in range(3):
            if a[c][r] == b:
                a[c][r] = 0
R = [0,0,0]
C = [0,0,0]
S = [0,0]
for i in range(3):
    for j in range(3):
        R[i] += a[i][j]  # よこ
        C[j] += a[i][j]  # たて
for i in range(3):  # ななめ
    S[0] += a[i][i]
    S[1] += a[i][2-i]
print('Yes' if 0 in R + C + S else 'No')

Submission status: Accepted

Solution code:
#Bingo
card = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = list([int(input()) for _ in range(N)])
a = [[0]*3 for _ in range(3)]
for bi in b:
    for i in range(3):
        for j in range(3):
            if bi == card[i][j]:
                a[i][j] = 1
                
ans = 'No'
#tate
for i in range(3):
    if a[0][i] == 1 and a[1][i] == 1 and a[2][i] == 1:
        ans = 'Yes'
            
#yoko
for i in range(3):
    if a[i][0] == 1 and a[i][1] == 1 and a[i][2] == 1:
        ans = 'Yes'
    
#naname
if a[0][0] == 1 and a[1][1] == 1 and a[2][2] == 1:
    ans = 'Yes'
if a[0][2] == 1 and a[1][1] == 1 and a[2][0] == 1:
    ans ='Yes'
print(ans)

Submission status: Accepted

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

ans = "No"

if not(sum(a[0]) and sum(a[1]) and sum(a[2]) and 
        sum([a[0][0],a[1][0],a[2][0]]) and sum([a[0][1],a[1][1],a[2][1]]) and sum([a[0][2],a[1][2],a[2][2]]) and
        sum([a[0][0],a[1][1],a[2][2]]) and sum([a[0][2],a[1][1],a[2][0]])):
    ans = "Yes"

print(ans)

Submission status: Accepted

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

for i in range(N):
    B = int(input())
    for c in range(3):
        for r in range(3):
            if A[c][r] == B:
                A[c][r] = 0

R = [0, 0, 0]
C = [0, 0, 0]
S = [0, 0]

for i in range(3):
    for j in range(3):
        R[i] += A[i][j]
        C[j] += A[i][j]

for i in range(3):
    S[0] += A[i][i]
    S[1] += A[i][2 - i]

print('Yes' if 0 in R + C + S else 'No')