hdu 5264 pog loves szh I
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5264
pog loves szh I
Description
Pog has lots of strings. And he always mixes two equal-length strings. For example, there are two strings: "abcd" and "efgh". After mixing, a new string "aebfcgdh" is coming.
However, szh thinks it is boring, so he reverses the second string, like changing "efgh" to "hgfe". Then mix them as usual, resulting in "ahbgcfde".
Now, here comes a problem. Pog is given a string after mixing by szh, but he wants to find the original two strings.
Hint : In this question, it needs a linefeed at the end of line at hack time.
Input
The first line has an integer, $T(1 \leq T \leq 100)$, indicating the number of cases.
Then follows T lines. Every lines has a string S, whose length is even and not more than 100, and only consists of lower-case characters('a'~'z').
Output
For each cases, please output two lines, indicating two original strings.
Sample Input
1
aabbca
Sample Output
abc
aba
For example, there are two strings: "abcd" and "efgh". After mixing, a new string "aebfcgdh" is coming.
#include<algorithm>
#include<iostream>
#include<string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
std::ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
string s1, s2, buf;
cin >> buf;
for (int i = ; buf[i]; i++) {
if (i & ) s2 = buf[i] + s2;
else s1 += buf[i];
}
cout << s1 << endl << s2 << endl;
}
return ;
}
hdu 5264 pog loves szh I的更多相关文章
- hdu 5264 pog loves szh I 水题
pog loves szh I Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- HDU 5264 pog loves szh I (字符串,水)
题意:设有两个串A和B,现将B反转,再用插入的形式合成一个串.如:A:abc B:efg:反转B先,变gfe:作插入,agbfce.现在给出一个串,要求还原出A和B. 思路:扫一遍O(n),串A在 ...
- hdu 5266 pog loves szh III(lca + 线段树)
I - pog loves szh III Time Limit:6000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I ...
- hdu 5265 pog loves szh II
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5265 pog loves szh II Description Pog and Szh are pla ...
- hdu 5265 pog loves szh II STL
pog loves szh II Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- HDU 5266 pog loves szh III(区间LCA)
题目链接 pog loves szh III 题意就是 求一个区间所有点的$LCA$. 我们把$1$到$n$的$DFS$序全部求出来……然后设$i$的$DFS$序为$c[i]$,$pc[i]$为$c ...
- HDU 5265 pog loves szh II (二分查找)
[题目链接]click here~~ [题目大意]在给定 的数组里选两个数取模p的情况下和最大 [解题思路]: 思路见官方题解吧~~ 弱弱献上代码: Problem : 5265 ( pog love ...
- HDU 5266 pog loves szh III ( LCA + SegTree||RMQ )
pog loves szh III Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Oth ...
- HDU 5266 pog loves szh III 线段树,lca
Pog and Szh are playing games. Firstly Pog draw a tree on the paper. Here we define 1 as the root of ...
随机推荐
- com学习(四)2——用 ATL 写第一个组件(vs2003)
步骤2.1:建立一个解决方案. 步骤2.2:在 该解决方案中,新建一个 vc++ 的 ATL 项目.示例程序叫 Simple2,并选择DLL方式,见图一.图二. 图一.新建 ATL 项目 图二.选择非 ...
- 跟我学 NHibernate (二)
1. 在 NHibernate 中使用事务, 主要代码如下: #region 事务 public IList<Customer> GetAll() { // 开启事物 using (ITr ...
- js正则表达式中匹配反引号
直接用反引号就可以了~ /`[\W\w\*]+`\.`[\W\w\*]+`/
- Java中自定泛型方法
泛型用到哪些集合:List Set Map List<String> list=new ArraList<String>(); list.add("美女") ...
- java排序练习
public void testSort3(){ List<String> str=new ArrayList<String>(); String st="12345 ...
- iOS 国际化
1.在APPproject的新建一个Localizable.strings File->new file--->Resource --->strings File 2.添加需要的语言 ...
- 详解H264视频格式-2016.01.28
专业名词解释 VCL(Video Coding Layer)视频编码层 NAL(Network Abstraction Layer)网络提取层 SPS(Sequence Parameter Set) ...
- 2.1Android底层开发需要哪些工具
开发.测试和调试Linux驱动.HAL程序库需要的工具: (1)JDK6或以上版本: (2)Eclipse3.4或以上版本: (3)ADT(用于开发Android应用程序): (4)CDT(用于开发A ...
- 蘑菇街iOS客户端应用源码
蘑菇街iOS客户端应用源码 随着蘑菇街由导购向电商转型,蘑菇街自己的IM也应运而生,IM起初只是用于商家和买家之间沟通的工具.后面我们问自己,既然已经有了用于客服的IM,为什么不自己做一个IM,用于公 ...
- iOS 层层推进实现代理模式
1.代理模式核心思想:A类委托B类做某件事,然后A类获取B类的执行的返回结果! 举例:女孩想去买电影票,但是自己不亲自去而是委托男孩了解电影电影票信息,同时女孩获得男孩买票的结果,代码模拟实现: /* ...