Bitstring is a string consisting of only 0s and 1s. Each element in the string is called a bit. A bitstring is called circular when the first and last bit are considered to be adjacent.
Given a circular bitstring of size n and a number k. You want to make all the bits to zeroes. There are two possible operations.
- Take a bit and flip it, the cost of this operation is 1.
- Take any k consecutive bits and flip them all, the cost of this operation is 0. Flipping a bit means that if it's a zero, change it to one; or if it's a one change it to zero.
You are also given q updates. In each update one bit will be flipped. After each update you have to print one line, the minimum cost to make all the bits to zeroes with the current bitstring.
Input
Input starts with 3 numbers: n, k, and q respectively. The following line contains a bitstring of length n. Then q lines each containing an index between 1 to n, denoting which bit to flip.
Constraints
- 2 ≤ k ≤ n ≤ 3 x 105
- 1 ≤ q ≤ 3 x 105
Output
For each update, print one line containing the query number and the minimum cost. Please see the samples for details.
Sample
Sample Input | Sample Output |
---|---|
5 3 2 10010 5 1 | 0 0 |
Notes
Bitstring | Cost | Explanation | |
---|---|---|---|
10010 | Initial Bitstring | ||
10011 | After First update | 0 | We can flip 4’th, 5’th and 1st bit simultaneously with the 2nd type of operations and make every bit 0 with cost 0. |
00011 | After Second update | 0 | We do the 2nd type of operations 4 times to achieve all 0 states. 00011 -> 01101 -> 11110 -> 00111 -> 00000 |