CF1085A.Right-Left Cipher
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp loves ciphers. He has invented his own cipher called Right-Left.
Right-Left cipher is used for strings. To encrypt the string s=s1s2…sn Polycarp uses the following algorithm:
- he writes down s1,
- he appends the current word with s2 (i.e. writes down s2 to the right of the current result),
- he prepends the current word with s3 (i.e. writes down s3 to the left of the current result),
- he appends the current word with s4 (i.e. writes down s4 to the right of the current result),
- he prepends the current word with s5 (i.e. writes down s5 to the left of the current result),
- and so on for each position until the end of s.
For example, if s="techno" the process is: "t" → "te" → "cte" → "cteh" → "ncteh" → "ncteho". So the encrypted s="techno" is "ncteho".
Given string t — the result of encryption of some string s. Your task is to decrypt it, i.e. find the string s.
波利卡普喜欢密码。他发明了一种名为“右-左”的自创密码。
“右-左”密码用于字符串。为加密字符串 s=s1s2…sn,波利卡普使用如下算法:
- 他先写下 s1;
- 然后将 s2 追加到当前字符串的右侧(即在当前结果的右边写下 s2);
- 接着将 s3 添加到当前字符串的左侧(即在当前结果的左边写下 s3);
- 再将 s4 追加到当前字符串的右侧(即在当前结果的右边写下 s4);
- 再将 s5 添加到当前字符串的左侧(即在当前结果的左边写下 s5);
- 依此类推,对 s 中每个字符依次执行该操作,直至处理完所有字符。
例如,若 s = "techno",则加密过程为:
"t" → "te" → "cte" → "cteh" → "ncteh" → "ncteho"。
因此,字符串 s = "techno" 的加密结果为 "ncteho"。
现给定字符串 t —— 它是某个字符串 s 经上述加密后得到的结果。你的任务是解密 t,即找出原始字符串 s。
输入格式
The only line of the input contains t — the result of encryption of some string s. It contains only lowercase Latin letters. The length of t is between 1 and 50, inclusive.
输入仅包含一行,即字符串 s 加密后的结果 t。t 仅由小写拉丁字母组成,其长度在 1 到 50 之间(含端点)。
输出格式
Print such string s that after encryption it equals t.
输出满足加密后等于 t 的字符串 s。
输入输出样例
输入#1
ncteho
输出#1
techno
输入#2
erfdcoeocs
输出#2
codeforces
输入#3
z
输出#3
z
输入解题思路,AI测评打分。不知道怎么写?