#P10312. [SHUPC 2024] 栅栏密码

[SHUPC 2024] 栅栏密码

Problem Description

The rail fence cipher (rail fence) is a very basic transposition cipher.

We arrange the plaintext Hello,World! as follows:

H...o...r
.e.l.,.o.l.!
..l...W...d

That is, we place the plaintext into a pattern like several \/\/\/, and then take out the characters row by row from left to right to form the ciphertext. For example, the first row is Hor, the second row is el,ol!, and the third row is lWd, so the final ciphertext is Horel,ol!lWd.

If the ciphertext arranged in the above way has hh rows, then the height of this rail fence cipher is defined as hh.

Now you are given the height hh and a line of ciphertext string ss. Please output one line containing the plaintext string plainplain.

Input Format

The first line contains an integer h (2h10)h\ (2\le h \le10), which is the height of the cipher.

The second line contains a string s (1s105)s\ (1\le |s| \le 10^5), which is the ciphertext.

Output Format

Output a string plainplain, which is the plaintext.

3
Horel,ol!lWd
Hello,World!
5
ccehgyaefnpeoobe{lcirg}epriec_ora_g
cyberpeace{railfence_cipher_gogogo}

Hint

Translated by ChatGPT 5