#P6388. [COCI 2007/2008 #4] LEKTIRA

[COCI 2007/2008 #4] LEKTIRA

Problem Description

Given a string, split it into three parts, reverse each part, and then output them in the original order of the parts. Since there are multiple ways to split the string, output the lexicographically smallest possible result.

Input Format

One line containing a string, which is the string to be split.

Output Format

One line containing a string, which is the resulting string. It must be lexicographically smallest.

dcbagfekjih
abcdefghijk
mobitel
bometil
anakonda
aanadnok

Hint

Constraints

For 100%100\% of the testdata, the length of the input string is guaranteed to be between 3503\sim 50.

Notes

This problem is translated from COCI2007-2008 CONTEST #4 T3 LEKTIRA

Translated by ChatGPT 5