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,与平常的单位有些不同。先解释下差异并记录。
4026 0
Gbit与GByte比较
|
8月前
|
资源调度 运维 容灾
中国广电云,全国首个多Region2.0架构升级正式完成并亮相2025CCBN!
2025年4月25日,中国国际广播电视信息网络展览会(CCBN)在北京圆满落幕,在中国广电集团的展台上,阿里云支持建设的“国家文化专网基础设施——中国广电云”接待国家广电总局领导及广电传媒行业专家的参观指导,安全自主、文化特色、全国覆盖、产业智能等中国广电云的鲜明特点给莅临展位的行业同仁留下了深刻的印象。
402 4
|
10月前
|
存储 关系型数据库 分布式数据库
PolarDB 开源基础教程系列 8 数据库生态
PolarDB是一款开源的云原生分布式数据库,源自阿里云商业产品。为降低使用门槛,PolarDB携手伙伴打造了完整的开源生态,涵盖操作系统、芯片、存储、集成管控、监控、审计、开发者工具、数据同步、超融合计算、ISV软件、开源插件、人才培养、社区合作及大型用户合作等领域。通过这些合作伙伴,PolarDB提供了丰富的功能和服务,支持多种硬件和软件环境,满足不同用户的需求。更多信息请访问[PolarDB开源官方网站](https://openpolardb.com/home)。
505 4
|
机器学习/深度学习 计算机视觉
深度学习在图像识别中的应用与挑战
本文深入探讨了深度学习技术在图像识别领域的应用,分析了当前主流的深度学习模型及其在图像识别中的优势和面临的挑战。通过具体案例分析,揭示了深度学习如何推动图像识别技术的边界,并讨论了未来可能的发展方向。
214 4
|
缓存 安全 数据安全/隐私保护
「小邓观点」分享几种常见的账户锁定原因
下期小邓将与大家分享账户锁定的解决方案。如果您有账户锁定方面的困扰,敬请期待!
1002 4
ly~
|
存储 缓存 算法
如何使用 C 语言实现高效的图形渲染?
使用 C 语言实现高效图形渲染可从选择图形库、优化数据结构与算法及利用硬件加速等方面着手。推荐使用 OpenGL 或 SDL 进行图形绘制。OpenGL 功能强大,支持 2D 和 3D 图形,需熟悉其绘图流程;SDL 则提供简单易用的接口。优化方面,合理选择数据结构如数组、哈希表等,使用高效算法如 LOD 可提升渲染速度。利用 GPU 加速和多线程渲染亦能显著提高效率。此外,纹理映射和管理也是关键,适当加载和缓存纹理,减少不必要的绘制操作如视口裁剪和背面剔除,均可增强渲染性能。
ly~
411 5
|
SQL 安全 关系型数据库
AWVS扫描在线站点实现安全评估
AWVS扫描在线站点实现安全评估
|
传感器 IDE 开发工具
基于Arduino的自行车转向指示灯
基于Arduino的自行车转向指示灯
258 0
|
Oracle 关系型数据库 Linux
|
前端开发
9款漂亮的纯css字体样式
9款漂亮的纯css字体样式
1427 0
9款漂亮的纯css字体样式

热门文章

最新文章