#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 rows, then the height of this rail fence cipher is defined as .
Now you are given the height and a line of ciphertext string . Please output one line containing the plaintext string .
Input Format
The first line contains an integer , which is the height of the cipher.
The second line contains a string , which is the ciphertext.
Output Format
Output a string , 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