#P7750. Recover the Original Word

    ID: 20937 Type: Default 1000ms 256MiB

Recover the Original Word

Recover the Original Word

Martin's eyes are playing tricks on him. Every time he blinks, the letters of a word he sees are rearranged in the following way (all positions refer to the state before the blink):

  • The last letter is moved and inserted between the 1st and 2nd letters.
  • The second-to-last letter is moved and inserted between the 2nd and 3rd letters.
  • In general, the $\displaystyle k\text{th}$ letter from the end is moved and inserted between the $\displaystyle k\text{th}$ and $\displaystyle (k+1)\text{th}$ letters.

For example, the word abcdef transforms into afbecd after one blink. Note that if Martin blinks again, the same transformation is applied once more.

Given the number of blinks \(X\) and the word Martin sees after blinking \(X\) times, find the original word before any blinking occurred.

The transformation for one blink can be described in \(1\leq i\leq n\) (with \(n\) being the length of the word) as follows (using 1-indexing):

[ \text{If } i \leq \lceil n/2 \rceil, \quad \text{then } \text{original}[i] = s[2i-1]. ] [ \text{If } i > \lceil n/2 \rceil, \quad \text{then } \text{original}[i] = s[2(n-i+1)]. ]

This describes the inverse for one blink. Since the blink transformation is applied \(X\) times, the original word is obtained by applying this inverse transformation \(X\) times.

inputFormat

The input consists of two lines:

  • The first line contains an integer \(X\) (\(X \geq 0\)), the number of times Martin blinked.
  • The second line contains the string \(s\) that Martin sees.

outputFormat

Output the original word in a single line.

sample

1
afbecd
abcdef

</p>