The K-th One, Under Fire
A binary array changes over time: F i flips position i, and K k asks for the position of the k-th 1 (or −1 if fewer than k ones exist).
Input: the first line has N and Q; the second line has the initial 0/1 array; each of the next Q lines is an operation.
Output: one line per K query.
Constraints:
- 1 ≤ N, Q ≤ 105
Sample Tests
Input 1
5 4 1 0 1 1 0 K 2 F 3 K 2 K 3
Output 1
3 4 -1
Input 2
1 2 0 F 1 K 1
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.