Akuna CapitalOA #17
K Smallest Substring
估计中等可在线判题
In a string consisting only of 0/1, choose a substring that contains exactly k ones; first minimize the length, and among equal lengths take the lexicographically smallest. The statement guarantees that an answer exists.
输入格式
The first line contains the binary string s; the second line contains the integer k. This site follows the original length range 1≤k≤|s|≤1000, and explicitly adds the statement's guarantee that 1≤k≤(the total number of 1s in s).
输出格式
Output the valid substring that is smallest by (length, lexicographic order).
样例 1
输入:
0101101
3
输出:
1011
样例 2
输入:
111
1
输出:
1
样例 3
输入:
0010100
1
输出:
1