#P16103. [ICPC 2019 NAIPC] Cutting Strings
[ICPC 2019 NAIPC] Cutting Strings
题目描述
You are given a string and an integer . You can remove at most non-intersecting substrings from . Your task is to find the alphabetically (i.e., dictionary order) largest resulting string.
For example, with string abcdcada and , you can choose the substrings [abc]d[ca]da and remove them to get dda.
输入格式
Each input will begin with a line with a single integer (), which is the number of cases you must solve.
Each of the next lines will contain an integer and a string (, ), separated by a space.
The total length of all strings in the input will be at most .
输出格式
Output the largest string, alphabetically, that you can get by removing or fewer non-intersecting substrings from .
4
2 abcdcada
1 ababb
2 ababb
1 dadbdcdbdad
dda
bb
bbb
ddcdbdad