Task DescriptionDiscussion (0)
Task :: Lektira
Mario is making up silly games again instead of reading Dostoevsky for school. The rules of his newestgame follow.
First he chooses a random word from the book. Then he splits the word in two arbitrary places to get three separate words. After that he reverses the order of the letters in each of those three words (exchanges the first and last etters, the second and second last and so on). Finally, he puts the three words back together in the same order in which they were before splitting.
First he chooses a random word from the book. Then he splits the word in two arbitrary places to get three separate words. After that he reverses the order of the letters in each of those three words (exchanges the first and last etters, the second and second last and so on). Finally, he puts the three words back together in the same order in which they were before splitting.
The goal of the game is to obtain the lexicographically smallest word possible. In other words, of all words that can be obtained by the above procedure, find one which would be earliest in a dictionary.
Write a program that plays Mario's game perfectly.
Write a program that plays Mario's game perfectly.
INPUT:
The first and only line of input contains Mario's chosen word, a string of lowercase letters of the English alphabet with no spaces. The input word will be between 3 and 50 characters long (inclusive).
The first and only line of input contains Mario's chosen word, a string of lowercase letters of the English alphabet with no spaces. The input word will be between 3 and 50 characters long (inclusive).
OUTPUT:
Output the best word on a single line.
Output the best word on a single line.
input
dcbagfekjih
dcbagfekjih
output
abcdefghijk
abcdefghijk
input
mobitel
mobitel
output
bometil
bometil
input
anakonda
anakonda
output
aanadnok
aanadnok
Submit Solution
Available Languages
Task info
Task Ratings
| Difficulty: | 3.4 (13 votes) |
| Quality: | 3.8 (11 votes) |
Acceptance Rate
Recent Submissions
Fastest Solutions
| User | Time |
|---|---|
| Daniel93 | 0 s. |
| tikva | 0 s. |
| Lovro-lpa | 0 s. |
| crusader | 0 s. |
| niktrk | 0 s. |
| halil | 0 s. |
| fizaaaa | 0 s. |
| aleksandarb | 0 s. |
| teodora | 0 s. |
| IlkicSlobodan | 0 s. |
Solved By
Home
Training
Competitions
Forum
FAQ