Sleepy
InterviewTime limit1sMemory limit256 MB
Given the word seen after X shuffles that weave the back half into the front half, recover the original word.
- Level
Medium5 of 10
- Topics
- Simulation, Math, String
- Solved
- No attempts yet
Problem
Seonyeong stayed awake for three days straight building data for the upcoming COCI. She has reached the point where she cannot write one more test, and her nerves are so worn out that nothing she looks at comes through correctly.
When Seonyeong blinks once while reading something, the back half of a word slips into the gaps of the front half. If the length is odd, the back part is one letter shorter. The letters move like this.
- The last letter moves between the first letter and the second letter.
- The second letter from the back moves between the second letter and the third letter.
- The -th letter from the back moves between the -th and the -th letter counted from the front.
For example, if Seonyeong is looking at the word "abcdef" and blinks once, the word becomes "afbecd". One more blink turns it into "adfcbe".
Seonyeong wrote one word, then blinked times, and now she wonders what she wrote at the start. Given and the word Seonyeong sees after blinks, write a program that recovers the original word.
Input
The first line contains (). The second line contains the word seen after blinks. The word consists of lowercase letters only, and its length is at least and at most .
Output
Print the word as it was before the blinks.