282
传统题
[CF1675E] 全局前移最小字典序 (Replace With the Previous, Minimize)
[CF1675E] 全局前移最小字典序 (Replace With the Previous, Minimize)
Problem Statement
You are given a lowercase string of length and an integer .
In one operation, choose any character and replace all occurrences of in with its preceding letter .
Find the lexicographically smallest string obtainable after at most operations.
Input
The first line contains (). Each test case consists of (, ) and a lowercase string of length . The sum of does not exceed .
Output
For each test case, output the lexicographically smallest resulting string.
Example
4
3 2
cbc
4 2
ecab
4 5
dbca
5 25
ihfaq
aaa
ccab
aaaa
aaaaa
Note
- Constraints:,,,。
- Source:Codeforces 1675E · Replace With the Previous, Minimize