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.

 1 #include<algorithm>
 2 #include<iostream>
 3 #include<string>
 4 using std::cin;
 5 using std::cout;
 6 using std::endl;
 7 using std::string;
 8 int main() {
 9 #ifdef LOCAL
10     freopen("in.txt", "r", stdin);
11     freopen("out.txt", "w+", stdout);
12 #endif
13     std::ios::sync_with_stdio(false);
14     int t;
15     cin >> t;
16     while (t--) {
17         string s1, s2, buf;
18         cin >> buf;
19         for (int i = 0; buf[i]; i++) {
20             if (i & 1) s2 = buf[i] + s2;
21             else s1 += buf[i];
22         }
23         cout << s1 << endl << s2 << endl;
24     }
25     return 0;
26 }

时间: 2024-08-06 03:52:29

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?pid=5264 Description pog拥有很多字符串,它喜欢将两个长度相等字符串交错拼在一起,如abcd与efgh,那么交错拼在一起就成了aebfcgdh啦!szh觉得这并不好玩,因此它将第二个字符串翻转了一遍,如efgh变成了hgfe,然后再将这两个字符串交错拼在一起,因此abcd与efg

hdu 5266 pog loves szh III 在线lca+线段树区间优化

题目链接:hdu 5266 pog loves szh III 思路:因为它查询的是区间上的lca,所以我们需要用在线lca来处理,达到单点查询的复杂度为O(1),所以我们在建立线段树区间查询的时候可以达到O(1*nlgn)的时间复杂度 ps:因为栈很容易爆,所以.....你懂的 -->#pragma comment(linker, "/STACK:1024000000,1024000000") /*****************************************

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?pid=5265 Description pog在与szh玩游戏,首先pog找到了一个包含n个数的序列,然后他在这n个数中挑出了一个数A,szh出于对pog的爱,在余下的n−1个数中也挑了一个数B,那么szh与pog的恩爱值为(A+B)对p取模后的余数,pog与szh当然想让恩爱值越高越好,并且他们

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/Others)Total Submission(s): 470    Accepted Submission(s): 97 Problem Description Pog and Szh are playing games. Firstly Pog draw a tree on the paper. He

bc #43(hdu 5265) pog loves szh II

pog loves szh II Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2115    Accepted Submission(s): 609 Problem Description Pog and Szh are playing games.There is a sequence with n numbers, Pog wil

HDU 5265 pog loves szh II (二分查找)

[题目链接]click here~~ [题目大意]在给定 的数组里选两个数取模p的情况下和最大 [解题思路]: 思路见官方题解吧~~ 弱弱献上代码: Problem : 5265 ( pog loves szh II ) Judge Status : Accepted RunId : 13961817 Language : G++ Author : javaherongwei Code Render Status : Rendered By HDOJ G++ Code Render Versio

HDU 5266 pog loves szh III (LAC)

问题描述 pog在与szh玩游戏,首先pog在纸上画了一棵有根树,这里我们定义1为这棵树的根,然后szh在这棵树中选了若干个点,想让pog帮忙找找这些点的最近公共祖先在哪里,一个点为S的最近公共祖先当且仅当以该点为根的子树包含S中的所有点,且该点深度最大.然而,这个问题是十分困难的,出于szh对pog的爱,他决定只找编号连续的点,即l i   ~r i   . 输入描述 若干组数据(不超过3  组n≥10000  或Q≥10000  ). 每组数据第一行一个整数n(1≤n≤300000)  ,表

HDU 5266 pog loves szh III (LCA)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5266 题目就是让你求LCA,模版题.注意dfs会栈溢出,所以要扩栈,或者用bfs写. 1 #pragma comment(linker, "/STACK:102400000,102400000") //扩栈 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 using nam

HDU 5266 pog loves szh III (线段树+在线LCA转RMQ)

题目地址:HDU 5266 这题用转RMQ求LCA的方法来做的非常简单,只需要找到l-r区间内的dfs序最大的和最小的就可以,那么用线段树或者RMQ维护一下区间最值就可以了.然后就是找dfs序最大的点和dfs序最小的点的最近公共祖先了. 代码如下: #include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #inc