| Cupertino Informatics Tournament |
|---|
| Закончено |
Bessie has a 1D keyboard with $$$N$$$ keys, with all the keys laid out in a row next to each other. She would like to construct a string, with the string having exactly $$$K$$$ occurrences of each character in the keyboard. However, since Bessie only has hooves, every time she presses a key, she ends up pressing two keys – the $$$i$$$th key and then immediately after, the $$$i + 1$$$th key. She can also choose to press either the first key by itself or the last key it itself as well. Bessie is curious – what is the smallest string lexicographically that she can create?
On the first line, there are space seperated integers $$$N$$$ ($$$1 \lt = N \lt = 26$$$) and $$$K$$$ ($$$1 \lt = K \lt = 10^5$$$). On the second line a string S of length N which contains distinct uppercase letters of the alphabet representing the keyboard.
The lexicographically minimum string that Bessie can create.
7 2 LOSTKEY
EYEYLLOSOSTKTK
Definition of lexicographically minimum: https://en.wikipedia.org/wiki/Lexicographic_order
| Название |
|---|


