CF1367A.Short Substrings
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice guesses the strings that Bob made for her.
At first, Bob came up with the secret string a consisting of lowercase English letters. The string a has a length of 2 or more characters. Then, from string a he builds a new string b and offers Alice the string b so that she can guess the string a.
Bob builds b from a as follows: he writes all the substrings of length 2 of the string a in the order from left to right, and then joins them in the same order into the string b.
For example, if Bob came up with the string a="abac", then all the substrings of length 2 of the string a are: "ab", "ba", "ac". Therefore, the string b="abbaac".
You are given the string b. Help Alice to guess the string a that Bob came up with. It is guaranteed that b was built according to the algorithm given above. It can be proved that the answer to the problem is unique.
爱丽丝需要猜出鲍勃为她构造的字符串。
首先,鲍勃构思了一个由小写英文字母组成的秘密字符串 a。字符串 a 的长度至少为 2。接着,鲍勃根据字符串 a 构造出一个新的字符串 b,并将字符串 b 提供给爱丽丝,让她据此推断出原始字符串 a。
鲍勃按如下方式从 a 构造 b:他将字符串 a 中所有长度为 2 的子串按从左到右的顺序依次写出,再将这些子串按相同顺序连接起来,形成字符串 b。
例如,若鲍勃构思的字符串 a 为 "abac",则 a 中所有长度为 2 的子串依次为:"ab"、"ba"、"ac"。因此,字符串 b = "abbaac"。
现给出字符串 b,请帮助爱丽丝推断出鲍勃所构思的字符串 a。题目保证 b 是严格按照上述算法生成的,且该问题的答案唯一。
输入格式
The first line contains a single positive integer t (1≤t≤1000) — the number of test cases in the test. Then t test cases follow.
Each test case consists of one line in which the string b is written, consisting of lowercase English letters (2≤∣b∣≤100) — the string Bob came up with, where ∣b∣ is the length of the string b. It is guaranteed that b was built according to the algorithm given above.
第一行包含一个正整数 t(1≤t≤1000),表示测试用例的数量。随后是 t 个测试用例。
每个测试用例由一行组成,该行包含字符串 b,其由小写英文字母构成(2≤∣b∣≤100),即 Bob 构造出的字符串,其中 ∣b∣ 表示字符串 b 的长度。保证 b 是根据上述算法构造而成的。
输出格式
Output t answers to test cases. Each answer is the secret string a, consisting of lowercase English letters, that Bob came up with.
输出 t 个测试用例的答案。每个答案均为 Bob 构造的密钥字符串 a,该字符串由小写英文字母组成。
输入输出样例
输入#1
4 abbaac ac bccddaaf zzzzzzzzzz
输出#1
abac ac bcdaf zzzzzz
说明/提示
The first test case is explained in the statement.
In the second test case, Bob came up with the string a="ac", the string a has a length 2, so the string b is equal to the string a.
In the third test case, Bob came up with the string a="bcdaf", substrings of length 2 of string a are: "bc", "cd", "da", "af", so the string b="bccddaaf".
第一个测试用例在题目描述中已作解释。
在第二个测试用例中,Bob 构造的字符串 a 为 "ac",字符串 a 的长度为 2,因此字符串 b 等于字符串 a。
在第三个测试用例中,Bob 构造的字符串 a 为 "bcdaf",字符串 a 的所有长度为 2 的子串为:"bc"、"cd"、"da"、"af",因此字符串 b = "bccddaaf"。
输入解题思路,AI测评打分。不知道怎么写?