본문 바로가기
python-algorithm

백준 2993 세 부분

by 무적김두칠 2022. 10. 18.
def sol(s):
    len_s = len(s)
    strings = []
    for i in range(1, len_s - 1):
        for j in range(1, len_s - 1):
            if i + j <= len_s - 1:
                strings.append(s[:i][::-1] + s[i:i + j][::-1] + s[i + j:][::-1])
    return(sorted(strings)[0])

s=input()
print(sol(s))

https://www.acmicpc.net/problem/2993

 

2993번: 세 부분

첫째 줄에 원섭이가 고른 단어가 주어진다. 고른 단어는 알파벳 소문자로 이루어져 있고, 길이는 3보다 크거나 같고, 50보다 작거나 같다.

www.acmicpc.net

1251번 문제와 같음

Same with #1251 problem

반응형

댓글