P17173 「MSOI R1」Echo

Background

:::epigraph[—— *A Little Ash*] We will eventually become an echo of ourselves. :::

Description

This is a valley, with two mountain peaks facing each other. Bai Feng and Mo Long stand on the two peaks. They want to pass a shared message $S$ to each other. The message has length $N$ and is a string consisting only of lowercase letters. Because there is an echo in the valley, this passing process will produce an “echo string”. The generation process is as follows: 1. First, Bai Feng shouts the entire string $S$ **from left to right**. 2. Then, Mo Long shouts the last $N-1$ characters of $S$ **from right to left**. 3. Next, Bai Feng shouts the first $N-2$ characters of $S$ **from left to right**. 4. Then, Mo Long shouts the last $N-3$ characters of $S$ **from right to left**. …… The whole process continues following the pattern above, until there are no characters left to shout. Then, concatenating all previously shouted characters in the shouting order forms the new “echo string”. Now, please output the “echo string” for the given string.

Input Format

One line: a string $S$ consisting only of lowercase letters.

Output Format

The “echo string” corresponding to string $S$.

Explanation/Hint

**[Sample Explanation #1]** In the sample, $S =$ `abcde`, $N=5$. The construction process of the “echo string” is as follows: 1. First, output the entire string $S$ from left to right: `abcde`. 2. Then, output the last $N-1$ characters of $S$ from right to left: `edcb`. 3. Next, output the first $N-2$ characters of $S$ from left to right: `abc`. 4. Then, output the last $N-3$ characters of $S$ from right to left: `ed`. 5. Finally, output the first $N-4$ characters of $S$ from left to right: `a`. 6. There are no characters left to output. Concatenate the outputs above from top to bottom to get `abcdeedcbabceda`. This is the constructed “echo string”, and you should output this “echo string”. **[Constraints]** This problem has $10$ test points. Each test point is worth $10$ points after passing. For $100\%$ of the data, $1 \le N \le 500$, and $S$ contains only lowercase letters. ::cute-table{tuack} |Test Point ID|$N$|Special Property| |:---:|:-:|:--:| | $1$ | $=1$ | None | | $2\sim 3$ | $\le 100$ | $S$ contains only the character $a$ | | $4\sim 5$ | ^ | $S$ is a palindrome string | | $6\sim 7$ | ^ | None | | $8\sim 9$ | $\le 300$ | None | | $10$ | $\le 500$ | None | Definition of a palindrome string: for a string $S = s_0 s_1 \cdots s_{n-1}$, a palindrome string satisfies $S = \operatorname{reverse}(S)$, where $\operatorname{reverse}(S) = s_{n-1} s_{n-2} \cdots s_0$. # Input Format One line: a string $S$ consisting only of lowercase letters. # Output Format The “echo string” corresponding to string $S$. # Hint **[Sample Explanation #1]** In the sample, $S =$ `abcde`, $N=5$. The construction process of the “echo string” is as follows: 1. First, output the entire string $S$ from left to right: `abcde`. 2. Then, output the last $N-1$ characters of $S$ from right to left: `edcb`. 3. Next, output the first $N-2$ characters of $S$ from left to right: `abc`. 4. Then, output the last $N-3$ characters of $S$ from right to left: `ed`. 5. Finally, output the first $N-4$ characters of $S$ from left to right: `a`. 6. There are no characters left to output. Concatenate the outputs above from top to bottom to get `abcdeedcbabceda`. This is the constructed “echo string”, and you should output this “echo string”. Translated by ChatGPT 5