Logo
(追記) (追記ここまで)

17003번 - Cutting Strings 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 512 MB47161333.333%

문제

You are given a string s and an integer k. You can remove at most k non-intersecting substrings from s. Your task is to find the alphabetically (i.e., dictionary order) largest resulting string.

For example, with string abcdcada and k=2, 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 c (1 ≤ c ≤ 2·105), which is the number of cases you must solve.

Each of the next c lines will contain an integer k and a string s (1 ≤ k ≤ |s| ≤ 105, s ∈ [a−z]*), separated by a space.

The total length of all strings in the input will be at most 106.

출력

Output the largest string, alphabetically, that you can get by removing k or fewer non-intersecting substrings from s.

제한

예제 입력 1

4
2 abcdcada
1 ababb
2 ababb
1 dadbdcdbdad

예제 출력 1

dda
bb
bbb
ddcdbdad

힌트

출처

University > North American Invitational Programming Contest > NAIPC 2019 I번

Contest > Open Cup > 2018/2019 Season > Stage 14: Grand Prix of America I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /