Problem D
Alternative Anagram
Languages
en
sv
Consider a string of
Input
A single line containing string
Output
If possible, print a string of length
If there is more than one solution, any one will do.
Explanation of Sample Inputs
In the first example, the substrings before rearrangement are “tral”, “rala”, “alal”, “lala”, and “alal”. Note that “alal” appears twice. After the rearrangement, all substrings are different.
In the third example, all substrings are different already in the input, so it suffices to print the original string.
Sample Input 1 | Sample Output 1 |
---|---|
tralalal |
allatral |
Sample Input 2 | Sample Output 2 |
---|---|
zzzz |
-1 |
Sample Input 3 | Sample Output 3 |
---|---|
annorlunda |
annorlunda |