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 aa consisting of lowercase English letters. The string aa has a length of 22 or more characters. Then, from string aa he builds a new string bb and offers Alice the string bb so that she can guess the string aa.

Bob builds bb from aa as follows: he writes all the substrings of length 22 of the string aa in the order from left to right, and then joins them in the same order into the string bb.

For example, if Bob came up with the string aa="abac", then all the substrings of length 22 of the string aa are: "ab", "ba", "ac". Therefore, the string bb="abbaac".

You are given the string bb. Help Alice to guess the string aa that Bob came up with. It is guaranteed that bb was built according to the algorithm given above. It can be proved that the answer to the problem is unique.

爱丽丝需要猜出鲍勃为她构造的字符串。

首先,鲍勃构思了一个由小写英文字母组成的秘密字符串 aa。字符串 aa 的长度至少为 22。接着,鲍勃根据字符串 aa 构造出一个新的字符串 bb,并将字符串 bb 提供给爱丽丝,让她据此推断出原始字符串 aa。

鲍勃按如下方式从 aa 构造 bb:他将字符串 aa 中所有长度为 22 的子串按从左到右的顺序依次写出,再将这些子串按相同顺序连接起来,形成字符串 bb。

例如,若鲍勃构思的字符串 aa 为 "abac",则 aa 中所有长度为 22 的子串依次为:"ab"、"ba"、"ac"。因此,字符串 bb = "abbaac"。

现给出字符串 bb,请帮助爱丽丝推断出鲍勃所构思的字符串 aa。题目保证 bb 是严格按照上述算法生成的,且该问题的答案唯一。

输入格式

The first line contains a single positive integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases in the test. Then tt test cases follow.

Each test case consists of one line in which the string bb is written, consisting of lowercase English letters (2≤∣b∣≤1002 \le |b| \le 100) — the string Bob came up with, where ∣b∣|b| is the length of the string bb. It is guaranteed that bb was built according to the algorithm given above.

第一行包含一个正整数 tt(1≤t≤10001 \le t \le 1000),表示测试用例的数量。随后是 tt 个测试用例。

每个测试用例由一行组成,该行包含字符串 bb,其由小写英文字母构成(2≤∣b∣≤1002 \le |b| \le 100),即 Bob 构造出的字符串,其中 ∣b∣|b| 表示字符串 bb 的长度。保证 bb 是根据上述算法构造而成的。

输出格式

Output tt answers to test cases. Each answer is the secret string aa, consisting of lowercase English letters, that Bob came up with.

输出 tt 个测试用例的答案。每个答案均为 Bob 构造的密钥字符串 aa,该字符串由小写英文字母组成。

输入输出样例

  • 输入#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 aa="ac", the string aa has a length 22, so the string bb is equal to the string aa.

In the third test case, Bob came up with the string aa="bcdaf", substrings of length 22 of string aa are: "bc", "cd", "da", "af", so the string bb="bccddaaf".

第一个测试用例在题目描述中已作解释。

在第二个测试用例中,Bob 构造的字符串 aa 为 "ac",字符串 aa 的长度为 22,因此字符串 bb 等于字符串 aa。

在第三个测试用例中,Bob 构造的字符串 aa 为 "bcdaf",字符串 aa 的所有长度为 22 的子串为:"bc"、"cd"、"da"、"af",因此字符串 bb = "bccddaaf"。

输入解题思路,AI测评打分。不知道怎么写?

首页