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:
ls=[int(s) for s in input().split()]
ls=ls+[int(s) for s in input().split()]
ls=ls+[int(s) for s in input().split()]
N=int(input())
for _ in range(N):
  a=int(input())
  for i in range(9):
    if ls[i]==a:
      ls[i]=0
if ((ls[0]+ls[1]+ls[2])
    *(ls[3]+ls[4]+ls[5])
    *(ls[6]+ls[7]+ls[8])
    *(ls[0]+ls[3]+ls[6])
    *(ls[1]+ls[4]+ls[7])
    *(ls[2]+ls[5]+ls[8])
    *(ls[0]+ls[4]+ls[8])
    *(ls[2]+ls[4]+ls[6]))==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    from itertools import product
    BINGO = [[(i, j) for j in range(3)] for i in range(3)] + \
            [[(j, i) for j in range(3)] for i in range(3)] + \
            [[(0, 0), (1, 1), (2, 2)], [(0, 2), (1, 1), (2, 0)]]
    C = {A[i][j]:(i, j) for i, j in product(range(3), repeat=2)}
    D = tuple(map(lambda x: C.get(x, None), b))
    for B in BINGO:
        if all(p in D for p in B):
            return True
    return False


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(YES if solve(A, N, b) else NO)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#ABC157B
def judge(A):
    flag = 'No'
    for j in range(3):
        if A[0][j]==0 and A[1][j]==0 and A[2][j]==0:
            flag = 'Yes'
            break
        if A[j][0]==0 and A[j][1]==0 and A[j][2]==0:
            flag = 'Yes'
            break
    if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
        flag = 'Yes'
    elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
        flag = 'Yes'
    print(flag)
    
def main():
    import sys
    A = [list(map(int, sys.stdin.readline().split())) for _ in range(3)]
    N = int(sys.stdin.readline())
    B = [int(sys.stdin.readline()) for _ in range(N)]
    #print(A)
    #print(B)
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                A[i][j] =0
    #print(A)
    judge(A)



        


if __name__ == '__main__':
    main()

Submission status: Accepted

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

N = int(input())
b = [0 for i in range (N)]
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:
      Ab[i][j] = 1
isbingo = False
for i in range(3):
  if (Ab[0][i] == Ab[1][i] == Ab[2][i] == 1\
      or Ab[i][0] == Ab[i][1] == Ab[i][2] == 1):
    isbingo = True
if (Ab[0][0] == Ab[1][1] == Ab[2][2] == 1\
   or Ab[0][2] == Ab[1][1] == Ab[2][0] == 1):
  isbingo = True
if isbingo:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a=[]
c=[[False] * 3 for i in range(3)]
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()))

for i in b:
    for j in range(3):
        if(i in a[j]):
            t=a[j].index(i)
            c[j][t]=True

ans="No"
for i in range(3):
    if(c[i][0]==True and c[i][1]==True and c[i][2]==True):ans="Yes"
for i in range(3):
    if(c[0][i]==True and c[1][i]==True and c[2][i]==True):ans="Yes"
for i in range(3):
    if(c[i][i]==False):break
else:ans="Yes"

for i in range(3):
    if(c[2-i][i]==False):break
else:ans="Yes"
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

N =  int(input())

for line in range(N):
	b=int(input())
	for a in range(3):
		for a_1 in range(3):
			if A[a][a_1]==b:
				A[a][a_1]=0
ans=[]
A_r=np.array(A).T.tolist()
ANS="No"
for k in range(3):
	if sum(A[k])==0 or sum(A_r[k])==0:
		ANS="Yes"
		break

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

print(ANS)

Submission status: Accepted

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

a=n3(3)
n=n0()
b=n2(n)

c=[[0,0,0] for _ in range(3)]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j]=1
ans="No"
for i in range(3):
    if sum(c[i])==3:
        ans="Yes"
    if c[0][i]+c[1][i]+c[2][i]==3:
        ans="Yes"
if c[0][0]+c[1][1]+c[2][2]==3 or c[0][2]+c[1][1]+c[2][0]==3:
    ans="Yes"
print(ans)

Submission status: Accepted

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

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

for l in lst:
    for i in range(3):
        if a[i] == l:
            a[i] = "〇"
        if b[i] == l:
            b[i] = "〇"
        if c[i] == l:
            c[i] = "〇"
            
if a[0] == a[1] == a[2]:
    print("Yes")
elif b[0] == b[1] == b[2]:
    print("Yes")
elif c[0] == c[1] == c[2]:
    print("Yes")
elif a[0] == b[0] == c[0]:
    print("Yes")
elif a[1] == b[1] == c[1]:
    print("Yes")
elif a[2] == b[2] == c[2]:
    print("Yes")
elif a[0] == b[1] == c[2]:
    print("Yes")
elif a[2] == b[1] == c[0]:
    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)]

for i,row in enumerate(a):
    for j,x in enumerate(row):
        if x in b:
            a[i][j] = 0
bingo = False
for row in a:
    if row == [0]*3:
        bingo = True
for j in range(3):
    if a[0][j] == 0 and a[1][j] == 0 and a[2][j] == 0:
        bingo = True
if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
    bingo = True
if a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
    bingo = True

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

Submission status: Accepted

Solution code:
def check(list1):
    if(list1[0][0]==0 and list1[1][1]==0 and list1[2][2]==0):
        return "Yes"
    if(list1[1][1]==0 and list1[0][2]==0 and list1[2][0]==0):
        return "Yes"
    for i in range(3):
        count=0
        for j in range(3):
            if(list1[i][j]==0):
                count+=1
        if(count==3):
            return "Yes"
    for i in range(3):
        count=0
        for j in range(3):
            if(list1[j][i]==0):
                count+=1
        if(count==3):
            return "Yes"
    return "No" 
list1=[]
for i in range(3):
    list2=list(map(int,input().strip().split()))[:3]
    list1.append(list2)
n=int(input())
list3=[]
for i in range(n):
    list3.append(int(input()))
for i in list3:
    for j in range(3):
        for k in range(3):
            if(list1[j][k]==i):
                list1[j][k]=0
print(check(list1))

Submission status: Accepted

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

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

if (3 in K.sum(axis=1)) or (3 in K.sum(axis=0)) or (K[0][0] == 1 and K[1][1] == 1 and K[2][2]) or (K[0][2] == 1 and K[1][1] == 1 and K[2][0]):
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
A = []
for i in range(3):
    A = A + [int(i) for i in input().split()]
N = int(input())
for i in range(N):
    b = int(input())
    if b in A:
        j = A.index(b)
        A[j] = -1
if (A[0] == -1 and A[3] == -1 and A[6] == -1) \
    or (A[1] == -1 and A[4] == -1 and A[7] == -1) \
    or (A[2] == -1 and A[5] == -1 and A[8] == -1) \
    or (A[0] == -1 and A[1] == -1 and A[2] == -1) \
    or (A[3] == -1 and A[4] == -1 and A[5] == -1) \
    or (A[6] == -1 and A[7] == -1 and A[8] == -1) \
    or (A[0] == -1 and A[4] == -1 and A[8] == -1) \
    or (A[2] == -1 and A[4] == -1 and A[6] == -1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
f = [];
for i in range(3):
    f.append([int(i) for i in input().split()]);

n = int(input());
v = [];

for i in range(n):
    k = int(input());
    v.append(k);

#print(f);
#print(v);

for val in v:
    for i in range(3):
        for j in range(3):
            if f[i][j] == val:
                f[i][j] = 0;

flag = False;

for i in range(3):
    curr = 0;
    for j in range(3):
        curr += f[i][j];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][i];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][j];
    if curr == 0:
        flag = True;
    curr = 0;
    for j in range(3):
        curr += f[j][2 - j];
    if curr == 0:
        flag = True;

if flag == True:
    print('Yes');
else:
    print('No');

Submission status: Accepted

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

N = int(input())

B = [int(input()) for i 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):
    judge = 0
    for j in range(3):
        judge += A[i][j]
    if judge == 0:
        print("Yes")
        exit()

for j in range(3):
    judge = 0
    for i in range(3):
        judge += A[i][j]
    if judge == 0:
        print("Yes")
        exit()

judge = 0

for k in range(3):
    judge += A[k][k]
if judge == 0:
    print("Yes")
    exit()

judge = 0

judge += A[0][2] + A[1][1] + A[2][0]
if judge == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
bingo = [0] * 9

A = input().split()
A += input().split()
A += input().split()

n = int(input())

for i in range(n):
    b = input()
    if b in A:
        bingo[A.index(b)] = 1        
    
ans = 'No'

for i in range(3):
    if bingo[i] == bingo[i + 3] == bingo[i + 6] == 1:
        ans = 'Yes'

for i in range(3):
    if bingo[3 * i] == bingo[3 * i + 1] == bingo[3 * i + 2] == 1:
        ans = 'Yes'
        
if bingo[0] == bingo[4] == bingo[8] == 1:
        ans = 'Yes'

if bingo[2] == bingo[4] == bingo[6] == 1:
        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())
for i in range(N):
    b = int(input())
    if A_1[0] == b:
        A_1[0] = 0
    if A_1[1] == b:
        A_1[1] = 0
    if A_1[2] == b:
        A_1[2] = 0
    if A_2[0] == b:
        A_2[0] = 0
    if A_2[1] == b:
        A_2[1] = 0
    if A_2[2] == b:
        A_2[2] = 0
    if A_3[0] == b:
        A_3[0] = 0
    if A_3[1] == b:
        A_3[1] = 0
    if A_3[2] == b:
        A_3[2] = 0
if A_1 == [0, 0, 0] or A_2 == [0, 0, 0] or A_3 == [0, 0, 0]:
    print("Yes")
    exit()
for j in range(3):
     if A_1[j] == 0 and A_2[j] == 0 and A_3[j] == 0:
         print("Yes")
         exit()
if A_1[0] == 0 and A_2[1] == 0 and A_3[2] == 0:
    print("Yes")
    exit()

if A_3[0] == 0 and A_2[1] == 0 and A_1[2] == 0:
    print("Yes")
    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)]

bingo = [[False, False, False] for _ in range(3)]

for i in range(3):
    for j in range(3):
        for b in B:
            if (A[i][j] == b):
                bingo[i][j] = True


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

if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    flag = True

if bingo[2][0] and bingo[1][1] and bingo[0][2]:
    flag = True

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

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 j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()
 
for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

flag=True
for i in range(3):
    if a[i][i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()
 
for i in range(3):
    if a[i][2-i]!=0:
        print("No")
        exit()
print("Yes")
exit()

Submission status: Accepted

Solution code:
l = list()
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    l.append(a1)
    l.append(a2)
    l.append(a3)
n = int(input())
for i in range(n):
    b = int(input())
    if b in l:
        l[l.index(b)] = 0
for i in range(3):
    if l[3 * i] == 0 and l[3 * i + 1] == 0 and l[3 * i + 2] == 0:
        print("Yes")
        exit()
    if l[i] == 0 and l[i + 3] == 0 and l[i + 6] == 0:
        print("Yes")
        exit()
if l[0] == 0 and l[4] == 0 and l[8] == 0:
    print("Yes")
    exit()
if l[2] == 0 and l[4] == 0 and l[6] == 0:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
c = list(map(int,input().split())) + list(map(int,input().split())) + list(map(int,input().split()))
n = int(input())
d = [0]*9
for i in range(n):
    m = int(input())
    for j in range(9):
        if c[j] == m:
            d[j] = 1
if (d[0],d[1],d[2]) == (1,1,1) or (d[3],d[4],d[5]) == (1,1,1) or (d[6],d[7],d[8]) == (1,1,1)\
    or (d[0],d[3],d[6]) == (1,1,1) or (d[1],d[4],d[7]) == (1,1,1) or (d[2],d[5],d[8]) == (1,1,1)\
        or (d[0],d[4],d[8]) == (1,1,1) or (d[2],d[4],d[6]) == (1,1,1):
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
A = np.zeros((3,3))

# ビンゴシートを作成する
A[0][0], A[0][1], A[0][2] = map(int, input().split())
A[1][0], A[1][1], A[1][2] = map(int, input().split())
A[2][0], A[2][1], A[2][2] = map(int, input().split())

# 結果を取得する
N = int(input())
N_list = []
for _ in range(N):
    N_list.append(int(input()))

# 結果をビンゴシートにあてこむ
for n in N_list:
    A = np.where(A==n, 0, A)

# 判定処理
result = 'No'
for i in np.all(A==0, axis=0):
    if i == True:
        result = 'Yes'
for i in np.all(A==0, axis=1):
    if i == True:
        result = 'Yes'
if np.all(np.diag(A)==0) == True or np.all(np.array([A[0,2], A[1,1], A[2,0]]) == 0) == True:
    result = 'Yes'
print(result)

Submission status: Accepted

Solution code:
import numpy as np

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

    N = int(input())

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

    for v in b:
        if v in A:
            index = A.index(v)
            A[index] = 0
    
    bingo_list = [
        [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 bingo in bingo_list:
        if sum(np.array(A)[bingo]) == 0:
            print("Yes")
            exit()
    
    print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
card = [[int(x) for x in input().split()] for y in range(3)]
bools = [[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == card[i][j]:
        bools[i][j] = 1
ok = False
for i in range(3):
  if (bools[i][0], bools[i][1], bools[i][2]) == (1,1,1) or (bools[0][i], bools[1][i], bools[2][i]) == (1,1,1):
    ok = True
if (bools[0][0],bools[1][1],bools[2][2]) == (1,1,1) or (bools[0][2], bools[1][1], bools[2][0]) == (1,1,1):
  ok = True
print("Yes" if ok else "No")

Submission status: Accepted

Solution code:
one = list(map(int, input().split()))
two = list(map(int, input().split()))
three = list(map(int, input().split()))
n = int(input())
out = [int(input()) for x in range(n)]


def judge(a_list):
    for i in a_list:
        if i not in out:
            return False

    return True


for_judge = [one, two, three]

for i in range(3):
    tmp = [one[i], two[i], three[i]]
    for_judge.append(tmp)


naname1 = [one[0], two[1], three[2]]
naname2 = [one[2], two[1], three[0]]

for_judge.append(naname1)
for_judge.append(naname2)

for a_list in for_judge:
    if judge(a_list):
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
a_list1, a_list2, a_list3 = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b_list = []
for _ in range(n):
    b_list.append(int(input()))
a_list = a_list1 + a_list2 + a_list3
hit_list = []
for i in range(len(a_list)):
    if a_list[i] in b_list:
        hit_list.append(i)
bingo_list = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
ans = 'No'
for bingo in bingo_list:
    if set(bingo) <= set(hit_list):
        ans = 'Yes'
        break
print(ans)

Submission status: Accepted

Solution code:
xs = []                                                                                                                                                                                                                                                                                    
for i in range(3):                                                                                                                                                                                                                                                                         
    x = list(map(int,input().split()))                                                                                                                                                                                                                                                     
    xs.append(x)                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                           
n = int(input())                                                                                                                                                                                                                                                                           
bs = {int(input()) for i in range(n)}                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                           
for i in range(3):                                                                                                                                                                                                                                                                         
    xs[i] = [x in bs for x in xs[i] ]                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                           
flags = []                                                                                                                                                                                                                                                                                 
for i in range(3):                                                                                                                                                                                                                                                                         
    flags.append(all(xs[i]))                                                                                                                                                                                                                                                               
for i in range(3):                                                                                                                                                                                                                                                                         
    flags.append(all([xs[0][i], xs[1][i], xs[2][i]]))                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                           
flags.append(all([xs[0][0], xs[1][1], xs[2][2]]))                                                                                                                                                                                                                                          
flags.append(all([xs[0][2], xs[1][1], xs[2][0]]))                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                           
if any(flags):                                                                                                                                                                                                                                                                             
    print("Yes")                                                                                                                                                                                                                                                                           
else:                                                                                                                                                                                                                                                                                      
    print("No")

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
n = int(input())
x = [int(input()) for i in range(n)]

yoko1 = ((a in x) and (b in x) and (c in x))
yoko2 = ((d in x) and (e in x) and (f in x))
yoko3 = ((g in x) and (h in x) and (i in x))
yoko = yoko1 or yoko2 or yoko3

tate1 = ((a in x) and (d in x) and (g in x))
tate2 = ((b in x) and (e in x) and (h in x))
tate3 = ((c in x) and (f in x) and (i in x))
tate = tate1 or tate2 or tate3

naname1 = ((a in x) and (e in x) and (i in x))
naname2 = ((c in x) and (e in x) and (g in x))
naname = naname1 or naname2

bingo = tate or yoko or naname

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

Submission status: Accepted

Solution code:
a = input().split()
b = input().split()
c = input().split()
list_ans =(a,b,c)
N = int(input())
bingo_list=[]

for i in range(N):
    bingo = input()
    bingo_list.append(bingo)


#横ビンゴ判定
def bingo_row(p,q):
    row_total= 0
    #p 横のリスト　q 出た値のリスト
    for i in range(3):
        if p[i] in q:
            row_total +=1
        else:
            return False
    if row_total == 3:
        return True
#縦ビンゴ判定
def bingo_column(p,q,r,s):
    batu = 0
    #pqr横リスト　s bingo_list
    for i in range(3):
        
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
                break
            else:
                batu +=1 
        else:
            batu +=1
    if batu == 3:
        return False
#斜めビンゴ判定
def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2] in s:
            return True
        elif p[2] in s and r[0] in s:
            return True
        else:
            return False
    else:
        return False

    
total = 0
for i in list_ans:
    if bingo_row(i, bingo_list):
        print('Yes')
        break
    elif bingo_column(a,b,c,bingo_list):
        print('Yes')
        break
    elif bingo_slash(a,b,c,bingo_list):
        print('Yes')
        break
    else:
        total += 1
if total == 3:
    print('No')

Submission status: Accepted

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

n=int(input())
for i in range(n):
  b=int(input())
  for j in range(9):
    if b==a[j]:
      m[j]=1
      break

ans=0
for i in range(3):
  if m[i]==1 and m[i+3]==1 and m[i+6]==1:
    ans=1
    break
  if m[i*3]==1 and m[i*3+1]==1 and m[i*3+2]==1:
    ans=1
    break
    
if m[0]==1 and m[4]==1 and m[8]==1:
  ans=1
if m[2]==1 and m[4]==1 and m[6]==1:
  ans=1
  
if ans:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import numpy as np

def is_bingo(bingo):
  tate0 = bingo[0,0]+bingo[1,0]+bingo[2,0]==0
  tate1 = bingo[0,1]+bingo[1,1]+bingo[2,1]==0
  tate2 = bingo[0,2]+bingo[1,2]+bingo[2,2]==0
  yoko0 = bingo[0,0]+bingo[0,1]+bingo[0,2]==0
  yoko1 = bingo[1,0]+bingo[1,1]+bingo[1,2]==0
  yoko2 = bingo[2,0]+bingo[2,1]+bingo[2,2]==0
  naname0 = bingo[0,0]+bingo[1,1]+bingo[2,2]==0
  naname1 = bingo[2,0]+bingo[1,1]+bingo[0,2]==0
  tate = tate0 or tate1 or tate2
  yoko = yoko0 or yoko1 or yoko2
  naname = naname0 or naname1
  bingo = tate or yoko or naname
  return "Yes" if bingo else "No"

bingo = [list(map(int, input().split())) for _ in range(3)]
bingo = np.array(bingo)

N = int(input())

for _ in range(N):
  b = int(input())
  i, j = np.where(bingo==b)
  bingo[i, j] = 0

print(is_bingo(bingo))

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)]
C = sum(A, [])
#print(C)
#8通り調べればよい
for i in range(N):
    for j in range(len(C)):
        if b[i] == C[j]:
            C[j] = 0


flag = False
#print(C)
#
if C[0] == C[1]==C[2]:
    flag = True
if C[3] == C[4]==C[5]:
    flag = True
if C[6] == C[7]==C[8]:
    flag = True
#
if C[0] == C[3]==C[6]:
    flag = True
if C[1] == C[4]==C[7]:
    flag = True
if C[2] == C[5]==C[8]:
    flag = True
#
if C[0] == C[4]==C[8]:
    flag = True
if C[2] == C[4]==C[6]:
    flag = True

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

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  A = [list(map(int,input().split())) for _ in range(3)]
  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
  #-
  
  if A[0][0] == A[0][1] == A[0][2] == 0:
    print('Yes')
    exit()
  if A[0][0] == A[1][0] == A[2][0] == 0:
    print('Yes')
    exit()
  if A[0][0] == A[1][1] == A[2][2] == 0:
    print('Yes')
    exit()
  if A[1][0] == A[1][1] == A[1][2] == 0:
    print('Yes')
    exit()
  if A[2][0] == A[2][1] == A[2][2] == 0:
    print('Yes')
    exit()
  if A[2][0] == A[1][1] == A[0][2] == 0:
    print('Yes')
    exit()
  if A[0][1] == A[1][1] == A[2][1] == 0:
    print('Yes')
    exit()
  if A[0][2] == A[1][2] == A[2][2] == 0:
    print('Yes')
    exit()
  print('No')
if __name__ == '__main__':
  main()

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

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

flag = 0

for i in range(3):
  if sum(A[i]) == 0:
    flag = 1

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

if A[0][0] + A[1][1] + A[2][2] == 0:
  flag = 1

if A[0][2] + A[1][1] + A[0][2] == 0:
  flag = 1

if flag == 1:
  print('Yes')
else:
  print('No')