#P40. [KBC002Ex] String 2
[KBC002Ex] String 2
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem 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 Format
Each test consists of multiple testcases.
For each testcase, you should input a string consisting of characters .
Output Format
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
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 .
Data Range
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 .