[구현] Lecture Note

2011. 1. 18. 12:43Algospot/구현

출처 : algospot.com

ime Limit: 5000 msMemory Limit: 65536 kb
Professor Lew teaches Algorithm course in Sonyusi University (소녀시대학교). It is his first year as a professor, so he spends a lot of time making lecture notes. He'll teach recursion and sorting algorithms in the next class, and he wants to make some examples which will be included in his lecture note.

While making some examples for his lecture note, he noticed that one of his work was quite difficult. The example was for sorting a string, and the exact process was as follows: First, the original string of length 2n is divided into n substrings, each of length 2. Then sort the n strings in lexicographic order, and then concatenate them to obtain the result string. Note that the sorting process will be performed on n strings, but not each of the n strings. The following example illustrates the process:

abbaaccb → ab ba ac cb → ab < ac < ba < cb → abacbacb
Since the process was quite confusing,

professor Lew decides to use a computer program for verification. Given an alphabetic string of even length, write a program that prints the result of the sorting process.

Input Specification
 The first line of the input contains one integer T, the number of test cases.

The first line of each test case contains a string. The length of the string will not exceed 1000, and will only contain lowercase alphabet letters.

Output Specification
For each test case, print the result in one line.

Sample Input

4
abbaaccb
dddcccbbbaaa
geegeegeegeebabybabybaby
oh

Sample Output

abacbacb
aababbccdcdd
babababybybyeeeeegeggege
oh






'Algospot > 구현' 카테고리의 다른 글

[구현] NOTE  (0) 2011.01.10
[구현] Hello World!  (0) 2011.01.10