首页 > 其他分享 >HDU 5264 pog loves szh I

HDU 5264 pog loves szh I

时间:2022-11-09 18:40:33浏览次数:44  
标签:HDU 5264 string int two szh pog include strings


Problem 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


T(1≤T≤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<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
const int maxn = 1005;
int T, n, m;
string a, b, s;

int main()
{
scanf("%d", &T);
while (T--)
{
cin >> s;
b = a = "";
for (int i = 0; s[i]; i++)
{
if (i & 1) b = s[i] + b;
else a = a + s[i];
}
cout << a << endl;
cout << b << endl;
}
}



标签:HDU,5264,string,int,two,szh,pog,include,strings
From: https://blog.51cto.com/u_15870896/5837707

相关文章

  • HDU 5639 Deletion
    ProblemDescriptionG with n verticesand m edges.Everytime,youcanselectseveraledgesanddeletethem.Theedgesselectedmustmeetthe......
  • HDU 5637 Transform
    ProblemDescriptionn integersaregiven.Foraninteger x youcandothefollowingoperations:+letthebinaryrepresentationof x be ......
  • HDU 1403 Longest Common Substring
    ProblemDescriptionGiventwostrings,youhavetotellthelengthoftheLongestCommonSubstringofthem.Forexample:str1=bananastr2=ciana......
  • HDU 4658 Integer Partition
    ProblemDescriptionGivenn,k,calculatethenumberofdifferent(unordered)partitionsofnsuchthatnopartisrepeatedkormoretimes.  ......
  • HDU 5638 Toposort
    ProblemDescriptionn verticesand m edges.Youareallowedtodeleteexact k InputT indicatingthenumberoftestcases.Fore......
  • HDU 4651 Partition
    ProblemDescriptionHowmanywayscanthenumbers1to15beaddedtogethertomake15?Thetechnicaltermforwhatyouareaskingisthe"numberofpart......
  • HDU 1028
    如果只有\(1\)数字,多项式为:\(1+x+x^2+x^3+\ldots\)。如果只有\(2\)数字,多项式为:\(1+x^2+x^4+x^6+\ldots\)。……如果只有\(k\)数字,多项式为:\(1+x^k+x^{2k}+x^{3......
  • B - K-th Number HDU - 6231 (二分 尺取)
    WindowsSource2017中国大学生程序设计竞赛-哈尔滨站题意给一个数组,在所有长度大于等于k的区间内,找出第\(k\)大的数,放到另一个数组中,然后在新数组中找到第M大的数。思......
  • HDU-1260 Tickets
    感觉题目还是比较水的,我这个蒟蒻也能写出来hh。思路:f[i]是前i个人(包含第i个)买票需要花费的总时间,第i个人买票所需时间,可以自己单买(f[i-1]+a[i]),也可以和前面那个人拼......
  • HDU 1686Oulipo ———————Hash or KMP
    OulipoOulipoTimeLimit:3000/1000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):22302    AcceptedSubmission(s):86......