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:
bingo = [list(map(int, input().split())) for i in range(3)]
n = int(input())
nums = [int(input()) for i in range(n)]
res = 'No'
for num in nums:
    for i in range(3):
        if num in bingo[i]:
            j = bingo[i].index(num)
            bingo[i][j] = 0
            if sum(bingo[i]) == 0 or sum([row[j] for row in bingo]) == 0:
                res = 'Yes'
            elif (i + j) % 2 == 0:
                if i + j == 2 and sum([bingo[0][2], bingo[1][1], bingo[2][0]]) == 0:
                    res = 'Yes'
                elif i == j and sum([bingo[0][0], bingo[1][1], bingo[2][2]]) == 0:
                    res = 'Yes'
            break
    if res == 'Yes':
        break
print(res)

Submission status: Accepted

Solution code:
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
n = int(input())
listA = [int(input()) for _ in range(n)]

list_bingo = [A1,A2,A3]

def check_bingo(list_bingo, N):
    for i in range(3):
        if list_bingo[i][0] == list_bingo[i][1] == list_bingo[i][2] == N or \
         list_bingo[0][i] == list_bingo[1][i] == list_bingo[2][i] == N:
            print('Yes')
            return
    if list_bingo[0][0] == list_bingo[1][1] == list_bingo[2][2] == N or \
    list_bingo[0][2] == list_bingo[1][1] == list_bingo[2][0] == N: 
        print('Yes')
        return
        
    print('No')
    return

listA = list(set(listA))
for i in range(len(listA)):
    for j in range(3):
        if listA[i] in list_bingo[j]:
            list_bingo[j][list_bingo[j].index(listA[i])] = 101
            
check_bingo(list_bingo, 101)

Submission status: Accepted

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

marked = []
for b in B:
    for i in range(3):
        if b not in A[i]:
            continue
        j = A[i].index(b)
        marked.append([i, j])

answer = 'No'
if (([0, 0] in marked and [1, 1] in marked and [2, 2] in marked) or
    ([0, 0] in marked and [0, 1] in marked and [0, 2] in marked) or
    ([1, 0] in marked and [1, 1] in marked and [1, 2] in marked) or
    ([2, 0] in marked and [2, 1] in marked and [2, 2] in marked) or
    ([0, 0] in marked and [1, 0] in marked and [2, 0] in marked) or
    ([0, 1] in marked and [1, 1] in marked and [2, 1] in marked) or
    ([0, 2] in marked and [1, 2] in marked and [2, 2] in marked) or
        ([2, 0] in marked and [1, 1] in marked and [0, 2] in marked)):
    answer = 'Yes'

print(answer)

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())
S = []
for _ in range(N):
    S.append(int(input()))
mat = [0]*9
A = A1+A2+A3

for i in range(9):
  if A[i] in S:
    mat[i] = 1
res = 'No'
if sum(mat[0:9:3])==3 or sum(mat[1:9:3])==3 or sum(mat[2:9:3])==3 or sum(mat[0:3])==3 or sum(mat[3:6])==3 or sum(mat[6:9])==3 or sum(mat[0:9:4])==3 or sum(mat[2:7:2])==3:
  res = 'Yes'
print(res)

Submission status: Accepted

Solution code:
def z():
    print("Yes")
    exit()


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

n = int(input())

for i in range(n):
    t = int(input())
    for y in range(3):
        for x in range(3):
            if a[y][x] == t:
                a[y][x] = -1
# print(a)

for i in range(3):
    if sum(a[i]) == -3:
        z()

for i in range(3):
    if a[0][i] + a[1][i] + a[2][i] == -3:
        z()

if a[0][0] + a[1][1] + a[2][2] == -3:
    z()

if a[0][2] + a[1][1] + a[2][0] == -3:
    z()
print("No")

Submission status: Accepted

Solution code:
NUM = 3
MAX_N = 100
def check(ty, yx, n):
    flg = False
    ty[yx[n]] += 1
    if NUM == ty[yx[n]]:
        flg = True
    return flg

def check_naname(nnm, y, x, n):
    flg = False
    if y[n] == x[n]:
        nnm[0] += 1
        if (NUM == nnm[0]):
            flg = True
    if y[n] == NUM - x[n] - 1:
        nnm[1] += 1
        if (NUM == nnm[1]):
            flg = True
    return flg

def main():
    y = [-1] * MAX_N
    x = [-1] * MAX_N
    for i in range(NUM):
        *A, = map(int, input().split())
        for j in range(NUM):
            A[j] -= 1
            y[A[j]] = i
            x[A[j]] = j
    N = int(input())
    tate = [0] * NUM
    yoko = [0] * NUM
    naname = [0] * 2
    flg = False
    for i in range(N):
        b = int(input())
        b -= 1
        if -1 == y[b]:
            continue
        flg = check(yoko, y, b)
        if flg:
            break
        flg = check(tate, x, b)
        if flg:
            break
        flg = check_naname(naname, y, x, b)
        if flg:
            break
    print("Yes" if flg else "No")
    return


main()

Submission status: Accepted

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

bingo=[[False for i in range(3)] for j in range(3)]
N=int(input())
for i in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                bingo[i][j]=True

flag=False
for i in range(3):
    if (bingo[i][0]&bingo[i][1]&bingo[i][2])|(bingo[0][i]&bingo[1][i]&bingo[2][i]):
        flag=True

if (bingo[0][0]&bingo[1][1]&bingo[2][2])|(bingo[0][2]&bingo[1][1]&bingo[2][0]):
    flag=True

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

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

bingo = [[0] * 3 for _ in range(3)]

for i in range(N):
    for h in range(3):
        for w in range(3):
            if A[h][w] == B[i]:
                bingo[h][w] = 1

# H側
ans = "No"
for h in range(3):
    cnt = 0
    for w in range(3):
        if bingo[h][w]:
            cnt += 1
    if cnt == 3:
        ans = "Yes"

for w in range(3):
    cnt = 0
    for h in range(3):
        if bingo[h][w]:
            cnt += 1
    if cnt == 3:
        ans = "Yes"

cnt = 0
for a in range(3):
    if bingo[a][a]:
        cnt += 1
    if cnt == 3:
        ans = "Yes"
cnt = 0
for a, b in zip([0, 1, 2], [2, 1, 0]):
    if bingo[a][b]:
        cnt += 1
    if cnt == 3:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
A1=[int(e) for e in input().split()]
A2=[int(f) for f in input().split()]
A3=[int(g) for g in input().split()]
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        if b==A1[j]:
            A1[j]= -1
        elif b==A2[j]:
            A2[j]= -1
        elif b==A3[j]:
            A3[j]= -1
if A1[0]==-1 and A2[0]==-1 and A3[0]==-1:
    print('Yes')
elif A1[1]==-1 and A2[1]==-1 and A3[1]==-1:
    print('Yes')
elif A1[2]==-1 and A2[2]==-1 and A3[2]==-1:
    print('Yes')
elif A1[0]==-1 and A1[1]==-1 and A1[2]==-1:
    print('Yes')
elif A2[0]==-1 and A2[1]==-1 and A2[2]==-1:
    print('Yes')
elif A3[0]==-1 and A3[1]==-1 and A3[2]==-1:
    print('Yes')
elif A1[0]==-1 and A2[1]==-1 and A3[2]==-1:
    print('Yes')
elif A3[0]==-1 and A2[1]==-1 and A1[2]==-1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
field = [[0]*3 for _ in range(3)]

for x in range(3):
    for y in range(3):
        field[x][y] = 0

def is_bingo(f):
    fl_v = [0 for _ in range(3)]
    fl_h = [0 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if f[i][j] == 1:
                fl_v[j]+=1
    if max(fl_v)==3:
        return True
    for i in range(3):
        for j in range(3):
            if f[i][j] == 1:
                fl_h[i]+=1
    if max(fl_h)==3:
        return True

    if f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
        return True

    if f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
        return True

    return False

bingo_num = [(-1,-1) for _ in range(101)]

for x in range(3):
    ax = list(map(int,input().split()))
    for y in range(3):
        bingo_num[ax[y]] = (x,y)

n = int(input())

for x in range(n):
    bn = bingo_num[int(input())]
    field[bn[0]][bn[1]] = 1

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

Submission status: Accepted

Solution code:
bingo=[input().split(' ') for _ in range(3)]

#print(bingo)
N=int(input())
get=[input() for _ in range(N)]
#print(get)

for i in range(3):
    for j in range(3):
        if bingo[i][j] in get:
            bingo[i][j] = 'A'

#print(bingo)

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

Submission status: Accepted

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

n = int(input())

for i in range(n):
    num = int(input())
    for j in [0,1,2]:
        for k in [0,1,2]:
         if num == card[j][k]:
             card[j][k] = 0
if card[0] == [0,0,0] or card[1] == [0,0,0] or card[2] == [0,0,0]:
    print('Yes')
elif [card[i][0] for i in range(3)] == [0,0,0] or [card[i][1] for i in range(3)] == [0,0,0] or [card[i][2] for i in range(3)] == [0,0,0]:
    print('Yes')
elif [card[0][0],card[1][1],card[2][2]] == [0,0,0] or [card[0][2],card[1][1],card[2][0]] == [0,0,0]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = [0] * 3

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

N = int(input())

b = [0] * N

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

x = [[0,0,0],[0,0,0],[0,0,0]]

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

ans = False

for i in range(3):
    if x[i] == [1,1,1]:
        ans = True
    
for i in range(3):
    if x[0][i] == 1 and x[1][i] == 1 and x[2][i] == 1:
        ans = True

if x[0][0] == 1 and x[1][1] == 1 and x[2][2] == 1:
    ans = True

if x[0][2] == 1 and x[1][1] == 1 and x[2][0] == 1:
    ans = True

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
nl = lambda: list(map(int, stdin.readline().split()))

a = [na() for _ in range(3)]
x = [[-1] * 3 for _ in range(3)]
n = ni()
for i in range(n):
    b = ni()
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                x[j][k] = 1
flag = False
for i in range(3):
    if x[i][0] == x[i][1] and x[i][1] == x[i][2] and x[i][0] == 1 or x[0][i] == x[1][i] and x[1][i] == x[2][i] and x[0][i] == 1:
        flag = True
if x[0][0] == x[1][1] and x[1][1] == x[2][2] and x[0][0] == 1:
    flag = True
if x[0][2] == x[1][1] and x[1][1] == x[2][0] and x[0][2] == 1:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(int(input())):
  bn = int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == bn: bingo[j][k] = -1

if (bingo[0][0] == -1 and bingo[0][1] == -1 and bingo[0][2] == -1) or \
   (bingo[1][0] == -1 and bingo[1][1] == -1 and bingo[1][2] == -1) or \
   (bingo[2][0] == -1 and bingo[2][1] == -1 and bingo[2][2] == -1) or \
   (bingo[0][0] == -1 and bingo[1][0] == -1 and bingo[2][0] == -1) or \
   (bingo[0][1] == -1 and bingo[1][1] == -1 and bingo[2][1] == -1) or \
   (bingo[0][2] == -1 and bingo[1][2] == -1 and bingo[2][2] == -1) or \
   (bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1) or \
   (bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:

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

arr = [[0 for i in range(3)] for j in range(3)]

#print(arr)
for j in range(3):
  for i in range(3):
    if A[i][j] in b:
      #print(A[i][j])
      arr[i][j] = 1
#print(arr)
f = 0
for i in range(3):
  if sum(arr[i][:]) == 3 and f == 0:
    print("Yes")
    f = 1

  if (arr[0][i] + arr[1][i] + arr[2][i] == 3) and f == 0:
    print("Yes")
    f = 1
    
if f == 0:
  if arr[0][0] + arr[1][1] + arr[2][2] == 3:
    print("Yes")
  elif arr[0][2] + arr[1][1] + arr[2][0] == 3:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

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

n=int(input())
for i in range(n):
  b=int(input())
  try:
    A[A.index(b)]=0
  except:
    continue

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

Submission status: Accepted

Solution code:
matrix = []
for i in range(3):
    matrix.append(list(map(int, input().split())))
col = [[0, 0, 0] for i in range(3)]
for _ in range(int(input())):
    n = int(input())
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == n:
                col[i][j] = 1
                break
f = 0
sd1 = col[0][2] + col[1][1] + col[2][0]
if sd1 == 3:
    print('Yes')
    exit()
sd = 0
for i in range(3):
    s, s1 = 0, 0
    sd += col[i][i]
    for j in range(3):
        s += col[i][j]
        s1 += col[j][i]
    if s == 3 or s1 == 3:
        f = 1
        break
if f:
    print('Yes')
else:
    if sd == 3:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
x1   = list(map(int, input().split()))
x2   = list(map(int, input().split()))
x3   = list(map(int, input().split()))
card = [x1, x2, x3]

numLen  = int(input())
numList = [int(input()) for _ in range(numLen)]
ans = "No"
for x in range(3):
    for y in range(3):
        for numList_i in range(numLen):
            if card[x][y] == numList[numList_i]:
                card[x][y] = "x"

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

if card[0][0] == "x" and card[1][1] == "x" and card[2][2] == "x":
    ans = "Yes"
if card[0][2] == "x" and card[1][1] == "x" and card[2][0] == "x":
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
import sys
b = [0] * 3
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

b[0] = list(input().split())
b[1] = list(input().split())
b[2] = list(input().split())

# print(b)
# print(c)

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


for i in range(3):
    if c[i][0] == c[i][1] == c[i][2] == 1:
        print("Yes")
        sys.exit()
    if c[0][i] == c[1][i] == c[2][i] == 1:
        print("Yes")
        sys.exit()
if c[0][0]==c[1][1]==c[2][2]==1:
    print("Yes")
    sys.exit()
if c[2][0]==c[1][1]==c[0][2]==1:
    print("Yes")
    sys.exit()
print("No")

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)]
# X = list(map(int, input().split()))
# n, k = map(int, input().split())
# p = math.ceil(sum(X)/n)
for i in range(3):
    for j in range(3):
        for k in range(n):
            if A[i][j] == B[k]:
                A[i][j] = 0
ans = False
# 横軸を確認
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += A[i][j]
    if cnt == 0:
        ans = True
# 縦軸を確認
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += A[j][i]
    if cnt == 0:
        ans = True
# 斜めの確認
cnt = 0
for i in range(3):
    cnt += A[i][i]
if cnt == 0:
    ans = True

cnt_2 = 0
for i in range(3):
    cnt_2 += A[i][2-i]
if cnt_2 == 0:
    ans = True

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

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)]
# X = list(map(int, input().split()))
# n, k = map(int, input().split())
# p = math.ceil(sum(X)/n)
for i in range(3):
    for j in range(3):
        for k in range(n):
            if A[i][j] == B[k]:
                A[i][j] = 0
judge = False
# 横軸を確認
for i in range(3):
    if A[i][1:] == A[i][:-1]:
        judge = True
# 縦軸を確認
for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(A[j][i])
    if tmp[1:] == tmp[:-1]:
        judge = True
# 斜めの確認
tmp_2 = []
for i in range(3):
    tmp_2.append(A[i][i])
if tmp_2[1:] == tmp_2[:-1]:
    judge = True
tmp_3 = []
for i in range(3):
    tmp_3.append(A[i][2-i])
if tmp_3[1:] == tmp_3[:-1]:
    judge = True
print("Yes") if judge else print("No")

Submission status: Accepted

Solution code:
#横判定
def judgehol(a, b):
    for i in range(3):
        flag = [False, False, False]
        for j in range(3):
            if a[i][j] in b:
                flag[j] = True
        if flag[0] and flag[1] and flag[2]:
            break
    return flag[0] and flag[1] and flag[2]

#縦判定
def judgever(a, b):
    for j in range(3):
        flag = [False, False, False]
        for i in range(3):
            if a[i][j] in b:
                flag[i] = True
        if flag[0] and flag[1] and flag[2]:
            break
    return flag[0] and flag[1] and flag[2]


#斜め判定
def judgecross(a, b):
    if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        return True
    elif a[0][2] in b and a[1][1] in b and a[2][0] in b:
        return True
    else:
        return False


a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
a = [a1, a2, a3]

n = int(input())

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


if judgehol(a, b) or judgever(a, b) or judgecross(a, b):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

l = [int(input()) for _ in range(n)]
ans = [[0 for _ in range(3)] for _ in range(3)]

for i in l:
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == i:
                ans[j][k] = 1
                break


flg = False
for i in range(3):
    if sum(ans[i]) == 3:
        flg = True
        break
    elif ans[0][i] + ans[1][i] + ans[2][i] == 3:
        flg = True
        break
    else:
        pass
    
if ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3:
    flg = True
    
print('Yes' if flg else 'No')

Submission status: Accepted

Solution code:
m = []
for _ in range(3):
	m.append(list(map(int, input().split())))
n = int(input())
nums = set()
for _ in range(n):
	nums.add(int(input()))

flag = True
#Row
for r in m:
	count = 0
	for elem in r:
		if elem in nums:
			count += 1
	if (count == len(r)):
		flag = False
		break

if flag:
	for r in zip(*m):
		count = 0
		for elem in r:
			if elem in nums:
				count += 1
		if (count == len(r)):
			flag = False
			break
if flag:
	count = 0
	for i in range(3):
		if m[i][i] in nums:
			count += 1
	if (count == 3):
		flag = False
if flag:
	if len({m[0][2],m[1][1],m[2][0]} & nums)==3:
		flag=False
if flag:
	print("No")
else:
	print("Yes")

Submission status: Accepted

Solution code:
bingo = []
flag = [0, 0, 0, 0, 0, 0, 0, 0, 0]
bingo.extend(input('').split(' '))
bingo.extend(input('').split(' '))
bingo.extend(input('').split(' '))
N = int(input(''))

for i in range(N):
    b = input('')
    if b in bingo:
        flag[bingo.index(b)] = 1

if(flag[0] * flag[1] * flag[2] == 1 or flag[3] * flag[4] * flag[5] == 1 or flag[6] * flag[7] * flag[8] == 1 or flag[0] * flag[3] * flag[6] == 1 or flag[1] * flag[4] * flag[7] == 1 or flag[2] * flag[5] * flag[8] == 1 or flag[0] * flag[4] * flag[8] == 1 or flag[2] * flag[4] * flag[6] == 1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

ar = []
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])

n = int(sys.stdin.readline())
ret = []
for i in range(n):
  b = int(sys.stdin.readline())
  if( b in ar):
    index = ar.index(b)
    ret.append(index)

result = "No"
for i in range(0,3):
  if( i*3+0 in ret and i*3+1 in ret and i*3+2 in ret ):
    result = "Yes"
  if( i+0*3 in ret and i+1*3 in ret and i+2*3 in ret ):
    result = "Yes"
if( 0 in ret and 4 in ret and 8 in ret ):
  result = "Yes"
if( 2 in ret and 4 in ret and 6 in ret ):
  result = "Yes"

print(result)



sys.stdout.flush()

Submission status: Accepted

Solution code:
#coding:utf-8
#!/usr/bin/python

A=[raw_input().split() for i in range(3)]
b=[]
N=int(raw_input())
for i in range(N):
    b.append(raw_input())

C=[[0 for i in range(3)] for j in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if(A[j][k]==b[i]):
               C[j][k]=1

#print C
kekka='No'

for i in range(3):
    m=0
    for j in range(3):
        m=m+C[i][j]
    if(m==3):
       kekka='Yes'
       break
            
for i in range(3):
    m=0
    for j in range(3):
        m=m+C[j][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][2-i]
    if(m==3):
       kekka='Yes'
       break

print kekka

Submission status: Accepted

Solution code:
def ball(card, number, state):
    for a in range(3):
        for b in range(3):
            if(card[a][b] == number):
                state[a][b] = 1

def check(state):
    for m in range(3):
        if(min(state[m]) == 1):
            return True
    for m in range(3):
        if(state[0][m] == 1 and state[1][m] == 1 and state[2][m] == 1):
            return True
    if(state[0][0] == 1 and state[1][1] == 1 and state[2][2] == 1):
        return True
    if(state[2][0] == 1 and state[1][1] == 1 and state[2][0] == 1):
        return True
    return False

                
state = [[0 for i in range(3)] for j in range(3)]
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for n in range(N):
    ball(card, int(input()), state)
if(check(state)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import numpy as np

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

for i in range(3):
    for j in range(N):
        if A[i][0] == n[j]:
            for k in range(N):
                if A[i][1] == n[k]:
                    for l in range(N):
                        if A[i][2] == n[l]:
                            print('Yes')
                            sys.exit()

for i in range(3):
    for j in range(N):
        if A[0][i] == n[j]:
            for k in range(N):
                if A[1][i] == n[k]:
                    for l in range(N):
                        if A[2][i] == n[l]:
                            print('Yes')
                            sys.exit()

for j in range(N):
    if A[0][0] == n[j]:
        for k in range(N):
            if A[1][1] == n[k]:
                for l in range(N):
                    if A[2][2] == n[l]:
                        print('Yes')
                        sys.exit()

for j in range(N):
    if A[2][0] == n[j]:
        for k in range(N):
            if A[1][1] == n[k]:
                for l in range(N):
                    if A[2][0] == n[l]:
                        print('Yes')
                        sys.exit()

print('No')

Submission status: Accepted

Solution code:
import sys

a_list = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]
bingo_list = [[0,0,0] for _ in range(3)]

for b in b_list:
    for i,row in enumerate(a_list):
        for j,n in enumerate(row):
            if n == b:
                bingo_list[i][j] = 1

for row in bingo_list:
    if sum(row) == 3:
        print('Yes')
        sys.exit()

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

if bingo_list[0][0] + bingo_list[1][1] + bingo_list[2][2] >= 3:
    print('Yes')
    sys.exit()

if bingo_list[0][2] + bingo_list[1][1] + bingo_list[2][0] >= 3:
    print('Yes')
    sys.exit()

print('No')

Submission status: Accepted

Solution code:
list_1 = list(map(int, input().split()))
list_2 = list(map(int, input().split()))
list_3 = list(map(int, input().split()))
list_bingo = list_1 + list_2 + list_3
list_check =[]
n = int(input())
for i in range(n):
    b = int(input())
    if b in list_bingo:
        list_check.append(list_bingo.index(b))
if 0 in list_check and 1 in list_check and 2 in list_check or 3 in list_check and 4 in list_check and 5 in list_check or 6 in list_check and 7 in list_check and 8 in list_check:
    print("Yes")
elif 0 in list_check and 3 in list_check and 6 in list_check or 1 in list_check and 4 in list_check and 7 in list_check or 2 in list_check and 5 in list_check and 8 in list_check:
    print("Yes")
elif 0 in list_check and 4 in list_check and 8 in list_check or 2 in list_check and 4 in list_check and 6 in list_check:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    a11, a12, a13 = LI()
    a21, a22, a23 = LI()
    a31, a32, a33 = LI()
    n = I()
    b = IR(n)
    if a11 in b and a12 in b and a13 in b:
        print('Yes')
    elif a21 in b and a22 in b and a23 in b:
        print('Yes')
    elif a31 in b and a32 in b and a33 in b:
        print('Yes')
    elif a11 in b and a21 in b and a31 in b:
        print('Yes')
    elif a12 in b and a22 in b and a32 in b:
        print('Yes')
    elif a13 in b and a23 in b and a33 in b:
        print('Yes')
    elif a11 in b and a22 in b and a33 in b:
        print('Yes')
    elif a13 in b and a22 in b and a31 in b:
        print('Yes')
    else:
        print('No')
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys

a_list = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b_list = [int(input()) for _ in range(n)]
bingo_list = [[0,0,0] for _ in range(3)]

for b in b_list:
    for i,row in enumerate(a_list):
        for j,n in enumerate(row):
            if n == b:
                bingo_list[i][j] = 1

for row in bingo_list:
    if sum(row) == 3:
        print('Yes')
        sys.exit()

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

if bingo_list[0][0] + bingo_list[1][1] + bingo_list[2][2] >= 3:
    print('Yes')
    sys.exit()

if bingo_list[0][2] + bingo_list[1][1] + bingo_list[2][0] >= 3:
    print('Yes')
    sys.exit()

print('No')

Submission status: Accepted

Solution code:
import sys

a = [[0] * 3] * 3
for i in range(0, 3, 1):
	a[i] = list(map(int, input().split()))
N = int(input())

for i in range(0, N, 1):
	b = int(input())
	for j in range(0, 3, 1):
		for k in range(0, 3, 1):
			if b == a[j][k]:
				a[j][k] = 0

for i in range(0, 3, 1):
	if a[i][0] == a[i][1] and a[i][1] == a[i][2]:
		print("Yes")
		sys.exit(0)
	elif a[0][i] == a[1][i] and a[1][i] == a[2][i]:
		print("Yes")
		sys.exit(0)

if a[0][0] == a[1][1] and a[1][1] == a[2][2]:
	print("Yes")
	sys.exit(0)
elif a[0][2] == a[1][1] and a[1][1] == a[2][0]:
	print("Yes")
	sys.exit(0)

print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# ビンゴゲーム
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))

N = int(input())
# 複数行標準入力
S = []
for _ in range(N):
    S.append(int(input()))  # S += [input()] とも書ける

for _S in S:
    for _l1 in range(len(l1)):
        if (_S == l1[_l1]):
            l1[_l1] = 0
    for _l2 in range(len(l2)):
        if (_S == l2[_l2]):
            l2[_l2] = 0
    for _l3 in range(len(l3)):
        if (_S == l3[_l3]):
            l3[_l3] = 0

isBingo = "No"
if (sum(l1) == 0 or sum(l2) == 0 or sum(l3) == 0 or l1[0] + l2[0] + l3[0] == 0 or l1[1] + l2[1] + l3[1] == 0 or l1[2] + l2[2] + l3[2] == 0 or l1[0] + l2[1] + l3[2] == 0 or l1[2] + l2[1] + l3[0] == 0):
    isBingo = "Yes"

print(isBingo)

Submission status: Accepted

Solution code:
# 屈辱的ウンコードいつか綺麗に書けるように
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = a1 + a2 +a3
n = int(input())
b = [int(input()) for i in range(n)]

for i in b:
    if i in a:
        a[a.index(i)] = 0

if a[0] == a[1] == a[2] == 0:
    print('Yes')
elif a[3] == a[4] == a[5] == 0:
    print('Yes')
elif a[6] == a[7] == a[8] == 0:
    print('Yes')
elif a[0] == a[3] == a[6] == 0:
    print('Yes')
elif a[1] == a[4] == a[7] == 0:
    print('Yes')
elif a[2] == a[5] == a[8] == 0:
    print('Yes')
elif a[0] == a[4] == a[8] == 0:
    print('Yes')
elif a[2] == a[4] == a[6] == 0:
    print('Yes')
else:
    print('No')