BOJ - 1251 - 단어 나누기

Updated:

import sys

def solution():
    word = str(input())
    data = []

    for i in range(1, len(word)):
        for j in range(i+1, len(word)):
            a, b, c = word[0:i], word[i:j], word[j:]
            data.append(
                a[::-1] + b[::-1] + c[::-1]
            )
    data.sort()
    print(data[0])

solution()

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

Categories:

Updated:

Leave a comment