#SGM0000042. Truy vấn kỳ nghỉ (Vacation Query)
Truy vấn kỳ nghỉ (Vacation Query)
Vacation Query
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Maintain a binary string under range flips and queries for the longest consecutive run of ones in a range.
Input
The first line contains and the second line a binary string . Each query c L R is:
1 L R: flip bits on .2 L R: print the longest consecutive run of1inside .
Output
Print one line for every type 2 query.
Subtasks
- 20 points: .
- 30 points: .
- 50 points: , .
Examples
Input
7 6
1101110
2 1 7
2 2 4
1 3 6
2 5 6
1 4 7
2 1 7
Output
3
1
0
7
Explanation
The first two answers are 3 and 1. Flipping gives 1110000, so has no ones. Flipping then gives 1111111, so the final answer is 7.