|
||||||||||
Rabbit's StringTime Limit: 40000/20000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 950 Accepted Submission(s): 308 Problem Description Long long ago, there lived a lot of rabbits in the forest. One day, the king of the rabbit kingdom got a mysterious string and he wanted to study this string. At first, he would divide this string into no more than k substrings. Then for each substring S, he looked at all substrings of S, and selected the one which has the largest dictionary order. Among those substrings selected in the second round, the king then choose one which has the largest dictionary order, and name it as a "magic string". Now he wanted to figure out how to divide the string so that the dictionary order of that "magic string" is as small as possible. Input There are at most 36 test cases. For each test case, the first line contains a integer k indicating the maximum number of substrings the king could divide, and the second line is the original mysterious string which consisted of only lower letters. The length of the mysterious string is between 1 and 105 and k is between 1 and the length of the mysterious string, inclusive. The input ends by k = 0. Output For each test case, output the magic string. Sample Input
Sample Output
Hint For the first test case, the king may divide the string into "b", "b" and "aa". For the second test case, the king may divide the string into "aba" and "ba". Source | ||||||||||
|