410780: GYM104103 A Homework
Description
Lana and Alan are twins, and they study in the same school. One day, they were given homework in which they had to make up a word using given letters. As they didn't want to be considered cheaters, they wanted to make up words that differ at every position.
Given a string of lowercase English letters $$$A$$$, find two words $$$B$$$ and $$$C$$$ that use all these letters (in other words, they both must be an anagram of $$$A$$$), such that $$$B$$$ and $$$C$$$ contain different letters in each place. These words don't have to be actual words of any real-world language.
InputThe input contains a string $$$A$$$, consisting of lowercase English letters. The length of $$$A$$$ is between $$$1$$$ and $$$1000$$$.
OutputIf an answer exists, print two lines containing words $$$B$$$ and $$$C$$$. Each word must be an anagram of $$$A$$$ (containing the same letters as $$$A$$$, possibly, in a different order). For each $$$i$$$ from $$$1$$$ to the length of $$$A$$$, $$$B_i$$$ must be different from $$$C_i$$$.
If it's impossible to make up such $$$B$$$ and $$$C$$$, print "IMPOSSIBLE". If there is more than one correct answer, you can print any of them.
ScoringSubtask | Points | Constraints |
1 | 30 | All letters in $$$A$$$ are distinct |
2 | 30 | The length of $$$A$$$ does not exceed $$$10$$$ |
3 | 40 | No additional constraints |
nalaOutput
alan lanaInput
abacabaOutput
IMPOSSIBLEInput
innopolisopenOutput
noepsilonnopi opinionnpoles