#K54222. Lexicographically Smallest Binary String

    ID: 29706 Type: Default 1000ms 256MiB

Lexicographically Smallest Binary String

Lexicographically Smallest Binary String

Given a binary string of length \(n\) and an integer \(k\), you are allowed to perform at most \(k\) swap operations on the string. In each operation, you can choose any two different positions in the string and swap their values. Your task is to transform the given binary string into the lexicographically smallest possible string by performing these swaps.

Note that if no beneficial swap is available, the string remains unchanged. The input guarantees that the string consists only of the characters '0' and '1'.

inputFormat

The input is read from standard input and consists of two lines:

  • The first line contains two integers \(n\) and \(k\) separated by a space, where \(n\) is the length of the binary string and \(k\) is the number of swaps allowed.
  • The second line contains a binary string of length \(n\).

outputFormat

Output to standard output the lexicographically smallest binary string obtainable after performing at most \(k\) swap operations.

## sample
5 2
11001
00111