개발자 톡
연습문제 톡
[21년 재직자 대회 예선] 비밀 메뉴
[21년 재직자 대회 예선] 비밀 메뉴 - 파이썬 풀이
- 등록일
- 2024-04-06 23:15:00
- 조회수
- 440
- 작성자
- s000715
deque를 사용해서 처음부터 끝까지 사용자가 입력한 버튼을 M개씩 비교하는 풀이가 가능합니다.
여기서 N과 K값은 사용하지 않기 때문에 _(언더바)로 받아줘도 됩니다.
import sys
input = sys.stdin.readline
from collections import deque
M, N, K = map(int, input().split())
secret = deque(list(map(int, input().split())))
user = deque(list(map(int, input().split())))
queue = deque()
while user:
queue.append(user.popleft())
if len(queue) > M: queue.popleft()
if queue == secret: break
print('secret' if secret == queue else 'normal')
한편 문제 자체는 '둘째 줄의 입력이 셋째 줄에 포함되어 있는가'만 판단하면 되기 때문에
_ = input()
print('secret' if input() in input() else 'normal')
이런 풀이도 가능합니다.
#[21년_재직자_대회_예선]_비밀_메뉴