#P38. [KBC002E] String 2
[KBC002E] String 2
Source
This problem is adapted from Long Long OJ. All rights reserved.
Description
There is a transfrom defined as follows:
Given a string consisting of characters , find the lexicographically smallest string that can be obtained after applying the following operations:
- Choose a non-empty substring of (let's call it ).
- Perfrom the transfrom once for each character in the substring .
- Reverse the substring .
Input
Each test consists of multiple testcases.
For each testcase, you should input a string consisting of characters .
Output
For each testcase, you should output a string representing the lexicographically smallest string that can be obtained after applying the operations above.
Samples
ACGTACGT
ACACACAC
AACGACGT
ACACACAG
Tips
Sample Explanation:
In the first testcase, It's best to choose the second to fourth characters () of .
In the second testcase, It's best to choose the last character () of .
There are tests, each of which is worth points:
- appeared in the sample input.
- All the characters in the string are the same.
- No additional constraints.
For of the testcases,
It is guaranteed that the sum of over all the testcases in one test does not exceed .