1. ๋ฌธ์ ์ค๋ช
๋น์ ์ ๋์์ ์ฌ์๊ธฐ๋ฅผ ๋ง๋ค๊ณ ์์ต๋๋ค. ๋น์ ์ ๋์์ ์ฌ์๊ธฐ๋ 10์ด ์ ์ผ๋ก ์ด๋, 10์ด ํ๋ก ์ด๋, ์คํ๋ ๊ฑด๋๋ฐ๊ธฐ 3๊ฐ์ง ๊ธฐ๋ฅ์ ์ง์ํฉ๋๋ค. ๊ฐ ๊ธฐ๋ฅ์ด ์ํํ๋ ์์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
- 10์ด ์ ์ผ๋ก ์ด๋: ์ฌ์ฉ์๊ฐ "prev" ๋ช ๋ น์ ์ ๋ ฅํ ๊ฒฝ์ฐ ๋์์์ ์ฌ์ ์์น๋ฅผ ํ์ฌ ์์น์์ 10์ด ์ ์ผ๋ก ์ด๋ํฉ๋๋ค. ํ์ฌ ์์น๊ฐ 10์ด ๋ฏธ๋ง์ธ ๊ฒฝ์ฐ ์์์ ์ฒ์ ์์น๋ก ์ด๋ํฉ๋๋ค. ์์์ ์ฒ์ ์์น๋ 0๋ถ 0์ด์ ๋๋ค.
- 10์ด ํ๋ก ์ด๋: ์ฌ์ฉ์๊ฐ "next" ๋ช ๋ น์ ์ ๋ ฅํ ๊ฒฝ์ฐ ๋์์์ ์ฌ์ ์์น๋ฅผ ํ์ฌ ์์น์์ 10์ด ํ๋ก ์ด๋ํฉ๋๋ค. ๋์์์ ๋จ์ ์๊ฐ์ด 10์ด ๋ฏธ๋ง์ผ ๊ฒฝ์ฐ ์์์ ๋ง์ง๋ง ์์น๋ก ์ด๋ํฉ๋๋ค. ์์์ ๋ง์ง๋ง ์์น๋ ๋์์์ ๊ธธ์ด์ ๊ฐ์ต๋๋ค.
- ์คํ๋ ๊ฑด๋๋ฐ๊ธฐ: ํ์ฌ ์ฌ์ ์์น๊ฐ ์คํ๋ ๊ตฌ๊ฐ(op_start ≤ ํ์ฌ ์ฌ์ ์์น ≤ op_end)์ธ ๊ฒฝ์ฐ ์๋์ผ๋ก ์คํ๋์ด ๋๋๋ ์์น๋ก ์ด๋ํฉ๋๋ค.
๋์์์ ๊ธธ์ด๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด video_len, ๊ธฐ๋ฅ์ด ์ํ๋๊ธฐ ์ง์ ์ ์ฌ์์์น๋ฅผ ๋ํ๋ด๋ ๋ฌธ์์ด pos, ์คํ๋ ์์ ์๊ฐ์ ๋ํ๋ด๋ ๋ฌธ์์ด op_start, ์คํ๋์ด ๋๋๋ ์๊ฐ์ ๋ํ๋ด๋ ๋ฌธ์์ด op_end, ์ฌ์ฉ์์ ์ ๋ ฅ์ ๋ํ๋ด๋ 1์ฐจ์ ๋ฌธ์์ด ๋ฐฐ์ด commands๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค. ์ด๋ ์ฌ์ฉ์์ ์ ๋ ฅ์ด ๋ชจ๋ ๋๋ ํ ๋์์์ ์์น๋ฅผ "mm:ss" ํ์์ผ๋ก return ํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด ์ฃผ์ธ์.
์ ํ์ฌํญ
- video_len์ ๊ธธ์ด = pos์ ๊ธธ์ด = op_start์ ๊ธธ์ด = op_end์ ๊ธธ์ด = 5
- video_len, pos, op_start, op_end๋ "mm:ss" ํ์์ผ๋ก mm๋ถ ss์ด๋ฅผ ๋ํ๋ ๋๋ค.
- 0 ≤ mm ≤ 59
- 0 ≤ ss ≤ 59
- ๋ถ, ์ด๊ฐ ํ ์๋ฆฌ์ผ ๊ฒฝ์ฐ 0์ ๋ถ์ฌ ๋ ์๋ฆฌ๋ก ๋ํ๋ ๋๋ค.
- ๋น๋์ค์ ํ์ฌ ์์น ํน์ ์คํ๋์ด ๋๋๋ ์๊ฐ์ด ๋์์์ ๋ฒ์ ๋ฐ์ธ ๊ฒฝ์ฐ๋ ์ฃผ์ด์ง์ง ์์ต๋๋ค.
- ์คํ๋์ด ์์ํ๋ ์๊ฐ์ ํญ์ ์คํ๋์ด ๋๋๋ ์๊ฐ๋ณด๋ค ์ ์ ๋๋ค.
- 1 ≤ commands์ ๊ธธ์ด ≤ 100
- commands์ ์์๋ "prev" ํน์ "next"์ ๋๋ค.
- "prev"๋ 10์ด ์ ์ผ๋ก ์ด๋ํ๋ ๋ช ๋ น์ ๋๋ค.
- "next"๋ 10์ด ํ๋ก ์ด๋ํ๋ ๋ช ๋ น์ ๋๋ค.
2. ์ถ๋ ฅ ์์

3. ๋ฌธ์ ๋ต์
def solution(video_len, pos, op_start, op_end, commands):
def get_total_seconds(t):
total_seconds = int(t[0:2]) * 60 + int(t[3:5])
return total_seconds
video_t = get_total_seconds(video_len)
op_start_t = get_total_seconds(op_start)
op_end_t = get_total_seconds(op_end)
pos_t = get_total_seconds(pos)
# ์คํ๋ ๊ฑด๋๋ฐ๊ธฐ
def check_and_skip_opening(pos_t):
if op_start_t <= pos_t <= op_end_t:
pos_t = op_end_t
return pos_t
for c in commands:
# 10์ด ์ ์ผ๋ก ์ด๋
if c == "prev":
pos_t = check_and_skip_opening(pos_t)
if pos_t < 10:
pos_t = 0
else:
pos_t -= 10
pos_t = check_and_skip_opening(pos_t)
# 10์ด ํ๋ก ์ด๋
if c == "next":
pos_t = check_and_skip_opening(pos_t)
if video_t - pos_t < 10:
pos_t = video_t
else:
pos_t += 10
pos_t = check_and_skip_opening(pos_t)
minutes = pos_t // 60
seconds = pos_t % 60
return f"{minutes:02d}:{seconds:02d}"