Position of the K-th One
Given a binary string, answer Q queries: where (1-based) is the K-th 1? Print −1 if there are fewer than K ones.
Input: the first line has the binary string; the second line has Q; the next Q lines each have one K.
Output: Q lines with the positions.
Constraints:
- 1 ≤ length, Q ≤ 105
Sample Tests
Input 1
10101 2 2 4
Output 1
3 -1
Input 2
0 1 1
Output 2
-1
Discussion (opens after you solve — no spoilers before)
No comments yet.