[Softeer]비밀메뉴 파이썬 풀이
Softeer 비밀메뉴¶
문제 page: https://softeer.ai/practice/info.do?eventIdx=1&psProblemId=623
.
문제 풀이 알고리즘: slicing
버튼의 i번째 버튼부터 i+M까지 slicing을 하여 secret button과 같은지 확인한다.
이 때 버튼의 마지막 index를 넘어가면 안되므로 이에 대한 처리가 필요하다
In [6]:
from IPython.display import Image
Image('비밀메뉴1.png')
Out[6]:
In [7]:
# 정답
M, N, K =[int(x) for x in input().split()]
secret = [int(x) for x in input().split()]
button = [int(x) for x in input().split()]
if N < M:
print('normal')
else:
is_secret = False
for i in range(N-M+1):
if secret == button[i:i+M]:
print('i: ', i) # <- 제출할 때 삭제
is_secret = True
break
if is_secret:
print('secret')
else:
print('normal')
3 10 5 1 4 5 3 3 1 2 4 1 4 5 1 4 i: 5 secret