#P17173. 「MSOI R1」回响

    ID: 19453 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度入门 上传者: 标签>洛谷原创O2优化洛谷月赛

「MSOI R1」回响

Background

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

Problem 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 SS to each other. The message has length NN 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 SS from left to right.
  2. Then, Mo Long shouts the last N−1N-1 characters of SS from right to left.
  3. Next, Bai Feng shouts the first N−2N-2 characters of SS from left to right.
  4. Then, Mo Long shouts the last N−3N-3 characters of SS 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 SS consisting only of lowercase letters.

Output Format

The “echo string” corresponding to string SS.

abcde
abcdeedcbabceda
abba
abbaabbaba
aaaaaa
aaaaaaaaaaaaaaaaaaaaa
a
a

Hint

[Sample Explanation #1]

In the sample, S=S = abcde, N=5N=5. The construction process of the “echo string” is as follows:

  1. First, output the entire string SS from left to right: abcde.
  2. Then, output the last N−1N-1 characters of SS from right to left: edcb.
  3. Next, output the first N−2N-2 characters of SS from left to right: abc.
  4. Then, output the last N−3N-3 characters of SS from right to left: ed.
  5. Finally, output the first N−4N-4 characters of SS 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 1010 test points. Each test point is worth 1010 points after passing.

For 100%100\% of the data, 1≤N≤5001 \le N \le 500, and SS contains only lowercase letters.

::cute-table{tuack}

Test Point ID NN Special Property
11 =1=1 None
2∼32\sim 3 ≤100\le 100 SS contains only the character aa
4∼54\sim 5 ^ SS is a palindrome string
6∼76\sim 7 None
8∼98\sim 9 ≤300\le 300
1010 ≤500\le 500

Definition of a palindrome string: for a string S=s0s1⋯sn−1S = s_0 s_1 \cdots s_{n-1}, a palindrome string satisfies S=reverse⁡(S)S = \operatorname{reverse}(S), where $\operatorname{reverse}(S) = s_{n-1} s_{n-2} \cdots s_0$.

Input Format

One line: a string SS consisting only of lowercase letters.

Output Format

The “echo string” corresponding to string SS.

Hint

[Sample Explanation #1]

In the sample, S=S = abcde, N=5N=5. The construction process of the “echo string” is as follows:

  1. First, output the entire string SS from left to right: abcde.
  2. Then, output the last N−1N-1 characters of SS from right to left: edcb.
  3. Next, output the first N−2N-2 characters of SS from left to right: abc.
  4. Then, output the last N−3N-3 characters of SS from right to left: ed.
  5. Finally, output the first N−4N-4 characters of SS 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