#SGM0000031. Bật tắt đèn (Light Switching)
Bật tắt đèn (Light Switching)
Light Switching
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are lights, initially off. Support range toggles and range counts of lights that are on.
Input
The first line contains . Each of the next lines is op l r.
0 l r: toggle every light from through .1 l r: count the lights that are on in that range.
Output
Print one line for every type 1 query.
Subtasks
- 20 points: , .
- 30 points: .
- 50 points: , , .
Examples
Input
4 5
0 1 2
0 2 4
1 2 3
0 2 4
1 1 4
Output
1
2
Explanation
After the first two toggles the state is 1 0 1 1, so range contains one on light. Toggling again gives 1 1 0 0, hence two lights are on.