Given a binary string, support the following two operations:
Update(i, l)
- take the substring starting at index i
of length l
within the binary string and reverse it. The reverse of string 0001
is 1000
. Given the string 0001
, Update(1, 3)
changes the string to 0100
.
Query(i, l)
- take the substring starting at index i
of length l
within the binary string, and compute the length of the longest substring that only contains 1's. In the event the substring does not contain the digit 1, the Query
should return 0.
Constraints
Input Specification
The first line of input contains two positive integers, and .
The next line contains a binary string of length .
The next lines each contain three integers, , , and . If is equal to , then the next operation
to perform is Update(i_q, l_q)
. Otherwise, will be equal to , and the next operation to perform is
Query(i_q, l_q)
.
Output Specification
For each Query
operation, output the answer on its own line. Output answers to Query
operations in the
order they're presented in the input.
In the event no Query
operations are requested, do not output anything.
Sample Input
4 3
0101
2 1 3
1 2 2
2 1 3
Sample Output
1
2
Comments