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 = sys.stdin.readline

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

n = int(input())
for i in range(n):
    b = int(input())

    if b in a1:
        a1[a1.index(b)] = 0
    if b in a2:
        a2[a2.index(b)] = 0
    if b in a3:
        a3[a3.index(b)] = 0

# 結果確認
if (a1[0] == a1[1] == a1[2] == 0) or (a2[0] == a2[1] == a2[2] == 0) or (a3[0] == a3[1] == a3[2] == 0) \
    or (a1[0] == a2[0] == a3[0] == 0) or (a1[1] == a2[1] == a3[1] == 0) or (a1[2] == a2[2] == a3[2] == 0) \
    or (a1[0] == a2[1] == a3[2] == 0) or (a1[2] == a2[1] == a3[0] == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A_list_yoko1 = list(map(int, input().split()))
A_list_yoko2 = list(map(int, input().split()))
A_list_yoko3 = list(map(int, input().split()))
N = int(input())
B_list = []
for i in range(N):
    B_list.append(int(input()))

A_list_tate1 = []
A_list_tate2 = []
A_list_tate3 = []
A_list_naname1 = []
A_list_naname2 = []

A_list_tate1.append(A_list_yoko1[0])
A_list_tate1.append(A_list_yoko2[0])
A_list_tate1.append(A_list_yoko3[0])
A_list_tate2.append(A_list_yoko1[1])
A_list_tate2.append(A_list_yoko2[1])
A_list_tate2.append(A_list_yoko3[1])
A_list_tate3.append(A_list_yoko1[2])
A_list_tate3.append(A_list_yoko2[2])
A_list_tate3.append(A_list_yoko3[2])
A_list_naname1.append(A_list_yoko1[0])
A_list_naname1.append(A_list_yoko2[1])
A_list_naname1.append(A_list_yoko3[2])
A_list_naname2.append(A_list_yoko1[2])
A_list_naname2.append(A_list_yoko2[1])
A_list_naname2.append(A_list_yoko3[0])

A_list_yoko1_c = []
A_list_yoko2_c = []
A_list_yoko3_c = []
A_list_tate1_c = []
A_list_tate2_c = []
A_list_tate3_c = []
A_list_naname1_c = []
A_list_naname2_c = []
for i in B_list:
    if i in A_list_yoko1:
        A_list_yoko1_c.append(A_list_yoko1.index(i))
    if i in A_list_yoko2:
        A_list_yoko2_c.append(A_list_yoko2.index(i))
    if i in A_list_yoko3:
        A_list_yoko3_c.append(A_list_yoko3.index(i))
    if i in A_list_tate1:
        A_list_tate1_c.append(A_list_tate1.index(i))
    if i in A_list_tate2:
        A_list_tate2_c.append(A_list_tate2.index(i))
    if i in A_list_tate3:
        A_list_tate3_c.append(A_list_tate3.index(i))
    if i in A_list_naname1:
        A_list_naname1_c.append(A_list_naname1.index(i))
    if i in A_list_naname2:
        A_list_naname2_c.append(A_list_naname2.index(i))

if len(A_list_naname1_c) == 3 or len(A_list_naname2_c) == 3 or len(A_list_tate1_c) == 3 or len(A_list_tate2_c) == 3 or len(A_list_tate3_c) == 3 or len(A_list_yoko1_c) == 3 or len(A_list_yoko2_c) == 3 or len(A_list_yoko3_c) == 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B[i] == A[j][k]:
                A[j][k] = 0             
if( ((A[0][0]==0) and (A[1][1]==0) and (A[2][2]==0)) or
   ((A[2][0]==0) and (A[1][1]==0) and (A[0][2]==0)) ):
    print('Yes');exit(0)


for j in range(len(A[0])): 
    if( ((A[j][0]==0) and (A[j][1]==0) and (A[j][2]==0)) or
       ((A[0][j]==0) and (A[1][j]==0) and (A[2][j]==0))    ):    
        print('Yes');
        exit(0)

print('No')

Submission status: Accepted

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

for i in range(9):
    if A[i] in B:
        A[i] = "Bingo"

if A[0] == A[1] == A[2]:
    print("Yes")
elif A[3] == A[4] == A[5]:
    print("Yes")
elif A[6] == A[7] == A[8]:
    print("Yes")
elif A[0] == A[3] == A[6]:
    print("Yes")
elif A[1] == A[4] == A[7]:
    print("Yes")
elif A[2] == A[5] == A[8]:
    print("Yes")
elif A[0] == A[4] == A[8]:
    print("Yes")
elif A[2] == A[4] == A[6]:
    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)]
card = [[False] * 3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        card[i][j] = A[i][j] in B
for triple in (
    ((0, 0), (0, 1), (0, 2)),
    ((1, 0), (1, 1), (1, 2)),
    ((2, 0), (2, 1), (2, 2)),
    ((0, 0), (1, 0), (2, 0)),
    ((0, 1), (1, 1), (2, 1)),
    ((0, 2), (1, 2), (2, 2)),
    ((0, 0), (1, 1), (2, 2)),
    ((0, 2), (1, 1), (2, 0)),
):
    ok = True
    for i, j in triple:
        if not card[i][j]:
            ok = False
    if ok:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
card = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if card[i][j] == num:
                card[i][j] = 0
for i in range(3):
    if  (card[0][i] == 0 and card[1][i] == 0 and card[2][i] == 0) or\
        (card[i][0] == 0 and card[i][1] == 0 and card[i][2] == 0):
        print("Yes")
        exit()
if  (card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0) or\
    (card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0):
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

A = []
b = []
B = [[0, 0, 0] for _ in range(3)]

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

N = int(input())

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

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

bingo = False

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

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

if B[2][2] == 1:
    if B[0][2] == 1 and B[1][2] == 1:
        bingo = True
    if B[2][0] == 1 and B[2][1] == 1:
        bingo = True
    
if bingo:
    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 in B:
  for j in range(3):
    for k in range(3):
      if A[j][k]==i:
        A[j][k]="X"

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

Submission status: Accepted

Solution code:
A_list1 = list(map(int, input().split()))
A_list2 = list(map(int, input().split()))
A_list3 = list(map(int, input().split()))
N = int(input())
B_list = []
for i in range(N):
    B_list.append(int(input()))

A_list1_c = []
A_list2_c = []
A_list3_c = []
for i in B_list:
    if i in A_list1:
        A_list1_c.append(A_list1.index(i))
    if i in A_list2:
        A_list2_c.append(A_list2.index(i))
    if i in A_list3:
        A_list3_c.append(A_list3.index(i))

for i in A_list1_c:
    if i in A_list2_c and i in A_list3_c:
        print("Yes")
        exit()
    if i == 0:
        if 1 in A_list2_c:
            if 2 in A_list3_c:
                print("Yes")
                exit()
    if i == 2:
        if 1 in A_list2_c:
            if 0 in A_list3_c:
                print("Yes")
                exit()
if len(A_list1_c) == 3 or len(A_list2_c) == 3 or len(A_list3_c) == 3:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
first_line = input().split()
second_line = input().split()
third_line = input().split()
 
first_line = [int(i) for i in first_line]
second_line = [int(i) for i in second_line]
third_line = [int(i) for i in third_line]

N = input()
N = int(N)



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


# arr = [[0]*3]*3
# print(arr)
# for i in range(3):
#     arr[0][i]= first_line[i]
#     print(arr)
# print(arr)
# for i in range(3):
#     arr[1][i]= second_line[i]
# for i in range(3):
#     arr[2][i]= third_line[i]

arr = []
arr.append(first_line)
arr.append(second_line)
arr.append(third_line)
carr = [[False for i in range(3)] for j in range(3)]

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

def yoko(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[i][j] != True:
                flag = 1
        if flag == 0 :
            return True    
    return False


def tate(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[j][i] != True:
                flag = 1
                break
        if flag == 0:

            return  True
    
    return False

def naname (carr):
    flag2 = 0
    flag1 = 0
    for i in range(3):
        if carr[i][i] != True:
            flag1 = 1

        if carr[i][3-i-1] != True:
            flag2 = 1;
    if flag1==0 or flag2 ==0:
        return True
    else:
        return False

def checker(carr):
    # print(tate(carr))
    # print(yoko(carr))
    # print(naname(carr))
    
    if not tate(carr)  and not yoko(carr) and not naname(carr):
        return 'No'
    else:
        return 'Yes' 
print(checker(carr))

Submission status: Accepted

Solution code:
def checkBingo(bList):
    ret = "No"
    for i in range(3):
        if bList[i][0] == -1 and bList[i][1] == -1 and bList[i][2] == -1:
            ret = "Yes"
    for i in range(3):
        if bList[0][i] == -1 and bList[1][i] == -1 and bList[2][i] == -1:
            ret = "Yes"
    if bList[0][0] == -1 and bList[1][1] == -1 and bList[2][2] == -1:
        ret = "Yes"
    if bList[0][2] == -1 and bList[1][1] == -1 and bList[2][0] == -1:
        ret = "Yes"
    return ret

def deleteNumber(bList, number):
    for i in range(3):
        for j in range(3):
            if bList[i][j] == number:
                bList[i][j] = -1

raw1 = map(int, input().split())
raw2 = map(int, input().split())
raw3 = map(int, input().split())
bingo = [list(raw1), list(raw2), list(raw3)]

n = int(input())
for i in range(n):
    number = int(input())
    deleteNumber(bingo, number)

print("{}".format(checkBingo(bingo)))

Submission status: Accepted

Solution code:
f=lambda:list(map(int,input().split()))
l=f()+f()+f()
n=int(input())
s=set()
for i in range(n):
  b=int(input())
  if b in l: s|={l.index(b)}
print(['No','Yes'][any(t<=s for t in [{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}])])

Submission status: Accepted

Solution code:
board=[list(map(int,input().split())) for _ in range(3)]
flag=[[False]*3 for _ in range(3)]
n=int(input())
for _ in range(n):
  tmp=int(input())
  for i in range(3):
    for j in range(3):
      if board[i][j]==tmp:
        flag[i][j]=True
if flag[0][0]==True and flag[0][1]==True and flag[0][2]==True:
  print('Yes')
elif flag[1][0]==True and flag[1][1]==True and flag[1][2]==True:
  print('Yes')
elif flag[2][0]==True and flag[2][1]==True and flag[2][2]==True:
  print('Yes')
elif flag[0][0]==True and flag[1][0]==True and flag[2][0]==True:
  print('Yes')
elif flag[0][1]==True and flag[1][1]==True and flag[2][1]==True:
  print('Yes')
elif flag[0][2]==True and flag[1][2]==True and flag[2][2]==True:
  print('Yes')
elif flag[0][0]==True and flag[1][1]==True and flag[2][2]==True:
  print('Yes')
elif flag[0][2]==True and flag[1][1]==True and flag[2][0]==True:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))

def check_bingo(bingo_card):
    bingo_cnt = 0
    ret = False
    bingo_list = [[0, 1, 2],
                  [3, 4, 5],
                  [6, 7, 8],
                  [0, 3, 6],
                  [1, 4, 5],
                  [2, 5, 8],
                  [0, 4, 8],
                  [2, 4, 6],]    

    for i in range(len(bingo_list)):
        for j in range(len(bingo_list[i])):
            if bingo_card[bingo_list[i][j]] == 0:
                bingo_cnt +=1
            else:
                break
        
        if bingo_cnt == 3:
            ret = True
            break
        else:
            bingo_cnt = 0
    
    return(ret)

def main():
    bingo_card = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
    cnt = 0
    for i in range(N):
        for j in range(len(bingo_card)):
            if b[i] == bingo_card[j]:
                bingo_card[j] = 0
                cnt += 1
                break
            else:
                pass

    if cnt <= 2:
        print('No')                
        
    elif 3 <= cnt <= 6:
        judge_bingo = check_bingo(bingo_card)
        if judge_bingo == True:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')                
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A = [[0 for i in range(3)] for j in range(3)]
t1 = list(map(int,input().split()))
t2 = list(map(int,input().split()))
t3 = list(map(int,input().split()))
A[0],A[1],A[2] = t1,t2,t3
N = int(input())
b = [int(input()) for i in range(N)]

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

for i in range(3):
    for j in range(3):
        for s in range(N):
            if b[s] == A[i][j]:
                P[i][j] = 1
o = 0
for i in range(3):
    if (P[i][0] and P[i][1] and P[i][2]) == 1: o=1
    if (P[0][i] and P[1][i] and P[2][i]) == 1: o=1
    if (P[0][0] and P[1][1] and P[2][2]) == 1: o=1
    if (P[0][2] and P[1][1] and P[2][0]) == 1: o=1
if o==1: print('Yes')
else: print('No')

Submission status: Accepted

Solution code:
A = list(map(str, input().split()))
A += list(map(str, input().split()))
A += list(map(str, input().split()))
a = []
N = int(input())
for i in range(N):
    a.append(input())
flag = 0
for i  in a:
    if i in A:
        A[A.index(i)] = "0"
B = []
C = []
D = []
E = []
F = []
for i in range(3):
    B.append(A[4*i])
    C.append(A[2*(i+1)])
    D.append(A[3*i])
    E.append(A[3*i+1])
    F.append(A[3*i+2])
    if "0" in A[i*3:i*3+3]:
        if A[i*3:i*3+3].count("0") == 3:
            flag = 1
if "0" in B:
    if B.count("0") == 3:
        flag = 1
if"0"in C:
    if C.count("0") == 3:
        flag = 1
if"0"in D:
    if D.count("0") == 3:
        flag = 1
if"0"in E:
    if E.count("0") == 3:
        flag = 1
if"0"in F:
    if F.count("0") == 3:
        flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a1 = na()
a2 = na()
a3 = na()

A = a1+a2+a3
C = [0,0,0,0,0,0,0,0,0]

n = ni()

for i in range(n):
    b = ni()
    if b in A:
        C[A.index(b)] = 1
    if sum(C[0:3]) == 3 or sum(C[3:6])==3 or sum(C[6:9]) == 3 or sum(C[::4]) == 3 or sum(C[2:7:2]) == 3 or sum(C[0::3]) == 3 or sum(C[1::3]) == 3 or sum(C[2::3]) == 3:
        print('Yes')
        exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
 
xy = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
num = [list(map(int, input().split())) for _ in range(n)] 
result = [[0,0,0],[0,0,0],[0,0,0]]
 
def input_b(xy:list, num:int, result:list):
    for i in range(3):
        if num in xy[i]:
            for j in range(3):
                if num==xy[i][j]:
                    result[i][j]=1
    return result
  
def check_result(result:list):
    for i in range(3):
        if 3 == np.array(result[i]).sum():
            return "Yes" 
    if 3 in np.array(result[0]) + np.array(result[1]) + np.array(result[2]):
        return "Yes"
    if 3 == result[0][0] + result[1][1] + result[2][2]:
        return"Yes"
    if 3 == result[0][2] + result[1][1] + result[2][0]:
        return"Yes"
    return "No"
 
for k in num:
    result=input_b(xy,k[0],result)
 
print(check_result(result))

Submission status: Accepted

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


    b.append(a)

    s.append(a)
p=[]
q=[]
for i in range(3):
    r=[]

    for j in range(3):
        r.append(b[j][i])
        if i==j:
            p.append(b[i][j])
        if i+j==2:
            q.append(b[i][j])

    r.sort()

    c.append(r)

d.append(p)
d.append(q)

l=0
n=int(input())

for k in range(n):
    m=int(input())
    for i in range(3):
        for j in range(3):
            if s[i][j] == m:
                s[i][j] = 0
            if c[i][j] == m:
                c[i][j] = 0
        if sum(s[i]) == 0:
            l += 1

        if sum(c[i]) == 0:
            l += 1

    for i in range(2):
        for j in range(3):
            if d[i][j] == m:
                d[i][j] = 0
        if sum(d[i]) == 0:
            l += 1

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

Submission status: Accepted

Solution code:
"""
B
"""
import sys

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

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

for i in range(3):
    cnt=0
    for j in range(3):
        cnt+=flag[i][j]
    if cnt==3:
        print("Yes")
        sys.exit()

for i in range(3):
    cnt=0
    for j in range(3):
        cnt+=flag[j][i]
    if cnt==3:
        print("Yes")
        sys.exit()

cnt=0
for i in range(3):
    cnt+=flag[i][i]
if cnt==3:
    print("Yes")
    sys.exit()

cnt=0
for i in range(3):
    cnt+=flag[i][2-i]
if cnt==3:
    print("Yes")
    sys.exit()

print("No")

Submission status: Accepted

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

for i in range(9):
    if A[i] in B:
        A[i] = "Bingo"

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

Submission status: Accepted

Solution code:
bingo_pattern = [[6, 7, 8], [3, 4, 5], [0, 1, 2], [0, 3, 6], [
    1, 4, 7], [2, 5, 8], [0, 4, 8], [6, 4, 2]]


def bingo_achieved(bingo_sheat_list, punch_number_list):

    punch_position_list = []
    for n in punch_number_list:
        try:
            punch_position_list.append(bingo_sheat_list.index(n))
        except ValueError:
            pass

    for p in bingo_pattern:
        if set(p) <= set(punch_position_list):
            return 'Yes'

    return 'No'


if __name__ == '__main__':
    bingo_sheat_list = input().split()
    bingo_sheat_list.extend(input().split())
    bingo_sheat_list.extend(input().split())
    punch_number = int(input())
    punch_number_list = [input() for i in range(punch_number)]
    print(bingo_achieved(list(map(int, bingo_sheat_list)),
                         list(map(int, punch_number_list))))

Submission status: Accepted

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

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

import numpy as np
np_card = np.array(A, dtype=np.int32)

def checked_card(card, numbers):
    tmp_card = np.full((3, 3), False)
    for number in numbers:
        tmp_card = np.logical_or(tmp_card, card == int(number))
    return tmp_card

def bingo_or_not(booled_card):
    if booled_card[0][0] and booled_card[0][1] and booled_card[0][2]:
        return "Yes" 
    if booled_card[1][0] and booled_card[1][1] and booled_card[1][2]:
        return "Yes" 
    if booled_card[2][0] and booled_card[2][1] and booled_card[2][2]:
        return "Yes" 
    if booled_card[0][0] and booled_card[1][0] and booled_card[2][0]:
        return "Yes" 
    if booled_card[0][1] and booled_card[1][1] and booled_card[2][1]:
        return "Yes" 
    if booled_card[0][2] and booled_card[1][2] and booled_card[2][2]:
        return "Yes" 
    if booled_card[0][0] and booled_card[1][1] and booled_card[2][2]:
        return "Yes" 
    if booled_card[0][2] and booled_card[1][1] and booled_card[2][0]:
        return "Yes" 
    return "No"

print(bingo_or_not(checked_card(np_card, called)))

Submission status: Accepted

Solution code:

# S, T = input().split()
# A, B = map(int, input().split())
# U = input()
# if S == U: A -= 1
# else: B -= 1
# print(A, B)

def main():
    A1 =list(map(int,input().split()))
    A2 =list(map(int,input().split()))
    A3 =list(map(int,input().split()))

    N = int(input())
    B =[]

    for i in range(N):
    
        B.append(int(input()))

    A=[]

    A.append(A1)
    A.append(A2)
    A.append(A3)

    flags = [[False,False,False],[False,False,False],[False,False,False]]


    for i in B:
        for j in range(3):

            if A[0][j] == i:
                flags[0][j] = True
            if A[1][j] == i:
                flags[1][j] = True
            if A[2][j] == i:
                flags[2][j] = True
            
            for k in range(3):
                if flags[k][0] == True and flags[k][1] == True and flags[k][2] == True:
                    print("Yes")
                    return
                if flags[0][k] == True and flags[1][k] == True and flags[2][k] == True:
                    print("Yes")
                    return

            if flags[0][0] == True and flags[1][1] == True and flags[2][2] == True : 
                print("Yes")
                return
            if flags[0][2] == True and flags[1][1] == True and flags[2][0] == True :
                print("Yes")
                return

    print("No")

main()

Submission status: Accepted

Solution code:
def checkbingo(map_):
  for i in range(3):
    if map_[i][0] * map_[i][1] * map_[i][2] == 1:
      return True
    if map_[0][i] * map_[1][i] * map_[2][i] == 1:
      return True
  if map_[0][0] * map_[1][1] * map_[2][2] == 1:
    return True
  if map_[0][2] * map_[1][1] * map_[2][0] == 1:
    return True
  return False 

A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A = [A1,A2,A3]
bingomap = [[0,0,0],[0,0,0],[0,0,0]]
N = int(input())
b = list()
ret = 'No'
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]:
      bingomap[j][A[j].index(b[i])] = 1
      break
  if i >= 2 :
    if checkbingo(bingomap) == True:
      ret = 'Yes'
      break
print(ret)

Submission status: Accepted

Solution code:
def bingo():    
    A=[]
    for i in range(3):
        A.extend(list(map(int, input().split())))
    N = int(input())
    n=[]
    while N>0:
        inp = int(input())
        if inp in A:
            n.append(inp)
        N-=1
    A = [A[:3],A[3:6],A[6:9], [A[0], A[4], A[8]], [A[2], A[4], A[6]], [A[0], A[3], A[6]], [A[1], A[4], A[7]], [A[2], A[5], A[8]]]
    for ele in A:
        if ele[0] in n and ele[1]in n and ele[2]in n:
            return 'Yes'
    return 'No'
print(bingo())

Submission status: Accepted

Solution code:
x = [input().split() for i in range(3)]
N = int(input())
b = [int(input()) for n in range(N)]
l = [[0]*3, [0]*3, [0]*3]
for val in b:
    for i in range(3):
        for j in range(3):
            if val == int(x[i][j]):
                l[i][j] = 1
if l[0][0] + l[0][1] + l[0][2] == 3:
    print('Yes')
elif l[1][0] + l[1][1] + l[1][2] == 3:
    print('Yes')
elif l[2][0] + l[2][1] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][0] + l[2][0] == 3:
    print('Yes')
elif l[0][1] + l[1][1] + l[2][1] == 3:
    print('Yes')
elif l[0][2] + l[1][2] + l[2][2] == 3:
    print('Yes')
elif l[0][0] + l[1][1] + l[2][2] == 3:
    print('Yes')
elif l[0][2] + l[1][1] + l[2][0] == 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
r1 = list(map(int,input().split()))
r2 = list(map(int,input().split()))
r3 = list(map(int,input().split()))
N = int(input())
array = []
for i in range(N):
    temp = int(input())
    array.append(temp)
#
if r1[0] in array and r1[1] in array and r1[2] in array or r2[0] in array and r2[1] in array and r2[2] in array or r3[0] in array and r3[1] in array and r3[2] in array:
    print("Yes")
    exit()
elif r1[0] in array and r2[0] in array and r3[0] in array or r1[1] in array and r2[1] in array and r3[1] in array or r1[2] in array and r2[2] in array and r3[2] in array:
    print("Yes")
    exit()
elif r1[0] in array and r2[1] in array and r3[2] in array or r1[2] in array and r2[1] in array and r3[0] in array:
    print("Yes")
    exit()
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
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)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


A = LIR(3)
n = I()
for _ in range(n):
    a = I()
    for i in range(3):
        for j in range(3):
            if A[i][j] == a:
                A[i][j] = 0

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

for i in range(3):
    ret = 0
    for j in range(3):
        ret += A[j][i]
    if ret == 0:
        flg = 1

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

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

if ret == 0:
    flg = 1


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

Submission status: Accepted

Solution code:
a = [[0,0,0],[0,0,0],[0,0,0]]
b =[[False,False,False], [False,False,False], [False,False,False]]
x = input()
z = x.split()
a[0][0] = z[0]
a[0][1] = z[1]
a[0][2] = z[2]

r = input()
t = r.split()
a[1][0] = t[0]
a[1][1] = t[1]
a[1][2] = t[2]

j = input()
k = j.split()
a[2][0] = k[0]
a[2][1] = k[1]
a[2][2] = k[2]


n = int(input())
for i in range(n):
  l = int(input())
  for s in range(3):
    for d in range(3):
      if(int(a[s][d]) == l):
        b[s][d] = True
        break

o = False;

if( (b[0][0]) & (b[0][1]) & (b[0][2])):
  o = True
elif( (b[1][0])& (b[1][1])& (b[1][2])):
  o = True
elif(b[2][0]& b[2][1]& b[2][2]):
  o = True
elif(b[0][0]& b[1][0]& b[2][0]):
  o = True
elif(b[0][1]& b[1][1]& b[2][1]):
  o = True
elif(b[0][2]& b[1][2]& b[2][2]):
  o = True
elif(b[0][0]& b[1][1]& b[2][2]):
  o = True
elif(b[0][2]& b[1][1]& b[2][0]):
  o = True

if(o == True):
  print("Yes")
else:
  print("No")