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;
}

总结

水题,不解释


目录
相关文章
Gbit与GByte比较
这段在看阿里的ECS指标,发现网络带宽的相关指标为Gbit/s,与平常的单位有些不同。先解释下差异并记录。
4524 0
Gbit与GByte比较
|
Java API Android开发
Android native应用开发简明教程 (1) - 本地开发武器库概览
native应用比起Java应用来,跟Android版本的相关性更高一些。 所以,这些API都是根据平台版本号分成不同的目录的。 我们来看看Android为我们提供了哪些API
6864 0
|
资源调度 运维 容灾
中国广电云,全国首个多Region2.0架构升级正式完成并亮相2025CCBN!
2025年4月25日,中国国际广播电视信息网络展览会(CCBN)在北京圆满落幕,在中国广电集团的展台上,阿里云支持建设的“国家文化专网基础设施——中国广电云”接待国家广电总局领导及广电传媒行业专家的参观指导,安全自主、文化特色、全国覆盖、产业智能等中国广电云的鲜明特点给莅临展位的行业同仁留下了深刻的印象。
601 4
|
存储 关系型数据库 分布式数据库
PolarDB 开源基础教程系列 8 数据库生态
PolarDB是一款开源的云原生分布式数据库,源自阿里云商业产品。为降低使用门槛,PolarDB携手伙伴打造了完整的开源生态,涵盖操作系统、芯片、存储、集成管控、监控、审计、开发者工具、数据同步、超融合计算、ISV软件、开源插件、人才培养、社区合作及大型用户合作等领域。通过这些合作伙伴,PolarDB提供了丰富的功能和服务,支持多种硬件和软件环境,满足不同用户的需求。更多信息请访问[PolarDB开源官方网站](https://openpolardb.com/home)。
706 4
|
人工智能 算法 数据挖掘
StoryTeller:字节、上海交大、北大共同推出的全自动长视频描述生成一致系统
StoryTeller是由字节跳动、上海交通大学和北京大学共同推出的全自动长视频描述生成系统。该系统通过音频视觉角色识别技术,结合低级视觉概念和高级剧情信息,生成详细且连贯的视频描述。StoryTeller在MovieQA任务中展现出比现有模型更高的准确率,适用于电影制作、视频内容分析、辅助视障人士等多个应用场景。
838 0
StoryTeller:字节、上海交大、北大共同推出的全自动长视频描述生成一致系统
|
缓存 安全 数据安全/隐私保护
「小邓观点」分享几种常见的账户锁定原因
下期小邓将与大家分享账户锁定的解决方案。如果您有账户锁定方面的困扰,敬请期待!
1849 4
|
安全 生物认证 区块链
智能家居安全:从理论到实践的全面解析
【6月更文挑战第22天】本文深入探讨了智能家居安全领域的核心问题,旨在为读者提供一套完整的安全解决方案。文章首先界定了智能家居安全的重要性和面临的挑战,随后详细分析了常见的安全威胁类型,并提出了相应的防御策略。通过案例分析,本文展示了如何将理论知识应用于实际中,以增强智能家居系统的安全性。最后,文章对智能家居安全的未来趋势进行了预测,并强调了持续研究的必要性。
|
JSON 搜索推荐 数据库
Django REST framework数据展示技巧:分页、过滤与搜索的实用配置与实践
Django REST framework数据展示技巧:分页、过滤与搜索的实用配置与实践
|
算法 安全 编译器
【C++ 17 新特性 折叠表达式 fold expressions】理解学习 C++ 17 折叠表达式 的用法
【C++ 17 新特性 折叠表达式 fold expressions】理解学习 C++ 17 折叠表达式 的用法
583 2