#P3870. [TJOI2009] 开关
[TJOI2009] 开关
Description
There are lights in a row, numbered from left to right as . Then operations are performed in order.
There are two types of operations:
- Given an interval , flip the state of every light whose index is in this interval (turn on lights that are off, and turn off lights that are on).
- Given an interval , output how many lights are on within this interval.
All lights are initially off.
Input Format
The first line contains two integers and , the number of lights and the number of operations, respectively.
Each of the next lines contains three integers , , and , where denotes the type of operation.
- If , it is the first type of operation.
- If , it is the second type of operation.
and are the left and right boundaries of the operation interval, respectively.
Output Format
For each operation of the second type, output one line containing an integer, the number of lights that are on in the queried interval.
4 5
0 1 2
0 2 4
1 2 3
0 2 4
1 1 4
1
2
Hint
Constraints.
For all testdata, it is guaranteed that , , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号