10268: CF EDU - Segment Tree P1 - Step 2 - B. K-th one
[Creator : ]
Description
In this problem, you need to add to the segment tree the operation of finding the $k$-th one.
Input
The first line contains two numbers $n,m\ (1≤n,m≤100,000)$, the size of the array and the number of operations.
The next line contains $n$ numbers $a_i$, the initial state of the array $(a_i∈\{0,1\})$.
The following lines contain the description of the operations. The description of each operation is as follows:
The next line contains $n$ numbers $a_i$, the initial state of the array $(a_i∈\{0,1\})$.
The following lines contain the desc
- $\text{1 i}$: change the element with index $i$ to the opposite.
- $\text{2 k}$: find the $k$-th one (ones are numbered from $0$, it is guaranteed that there are enough ones in the array).
Output
For each operation of the second type, print the index of the corresponding one (all indices in this problem are from 0).
Sample 1 Input
5 7
1 1 0 1 0
2 0
2 1
2 2
1 2
2 3
1 0
2 0
Sample 1 Output
0
1
3
3
1