Short Substrings

简介: Short Substrings

文章目录

一、Short Substrings

总结


一、Short Substrings

本题链接:Short Substrings


题目:

A. Short Substrings

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

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.


Input

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.


Output

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


Example

input

4

abbaac

ac

bccddaaf

zzzzzzzzzz

output

abac

ac

bcdaf

zzzzzz


Note

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".


本博客给出本题截图:

image.png

image.png

题意:对于一个字符串abcdef,每相邻的两个进行组合就变成了abbccddeef,现要求执行逆操作并输出

AC代码

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    cin >> n;
    while (n -- )
    {
        string a;
        cin >> a;
        cout << a[0];
        for (int i = 1; i < a.size(); i += 2 )
            cout << a[i];
        puts("");
    }
    return 0;
}

总结

水题,不解释


目录
相关文章
|
4月前
|
Python
TypeError: int() argument must be a string, a bytes原因
Python开发过程中,使用int()函数来转换或生成int类型的数据时,如果Python抛出并提示TypeError: int() argument must be a string, a bytes-like object or a real number, not 'complex',那么原因在于传递给int()函数的参数类型有误,正如TypeError的提示,int()函数的参数必须是string字符串(数值字符串)、类似字节对象、real number数字等,而不可以是complex复数类型的数据。
108 0
|
5月前
|
Java
Leetcode 467. Unique Substrings in Wraparound String
大概翻译下题意,有个无限长的字符串s,是由无数个「abcdefghijklmnopqrstuvwxy」组成的。现在给你一个字符串p,求多少个p的非重复子串在s中出现了?
19 0
TypeError: randint() received an invalid combination of arguments - got (int, int, int), but expecte
TypeError: randint() received an invalid combination of arguments - got (int, int, int), but expecte
526 0
浅谈String模块ascii_letters和digits
浅谈String模块ascii_letters和digits
173 0
浅谈String模块ascii_letters和digits
AtCoder Beginner Contest 225 F.String Cards(dp)
AtCoder Beginner Contest 225 F.String Cards(dp)
73 0
关于 error: invalid types ‘int[int]‘ for array subscript 的解决
关于 error: invalid types ‘int[int]‘ for array subscript 的解决
1025 0
关于 error: invalid types ‘int[int]‘ for array subscript 的解决
Way Too Long Words
Way Too Long Words
65 0
Way Too Long Words
成功解决ret = ret / rcountTypeError: unsupported operand type(s) for /: ‘str‘ and ‘int‘
成功解决ret = ret / rcountTypeError: unsupported operand type(s) for /: ‘str‘ and ‘int‘
成功解决ret = ret / rcountTypeError: unsupported operand type(s) for /: ‘str‘ and ‘int‘
1024. Palindromic Number (25)
#include #include #include #include #include using namespace std; bool judge(string s){ string st = s; reverse(st.
766 0