#P5511. Nuclear Warfare and Terrain Manipulation
Nuclear Warfare and Terrain Manipulation
Nuclear Warfare and Terrain Manipulation
The dark forces have the ability to alter the terrain, making it extremely difficult for the army to advance. To speed up the progress, Steve brings nuclear weapons to the front line to disrupt the terrain. At the same time, Steve is very concerned about the current state of the battlefield.
The front line is divided into \( n \) segments, each with an initial height of \( 0 \). During the decisive battle, \( m \) events occur. Each event is one of the following types:
- Type 1: Steve queries an interval \( [l,r] \) and asks for the number of segments whose height is less than a given value \( h \).
- Type 2: Steve uses nuclear weapons to reduce the height of each segment in \( [l,r] \) that is greater than \( h \) to \( h \) (i.e. if \( \text{height} > h \), then set it to \( h \)).
- Type 3: The dark forces modify the terrain by increasing the height of each segment in \( [l,r] \) that is less than \( h \) to \( h \) (i.e. if \( \text{height} < h \), then set it to \( h \)).
Furthermore, some test cases are online. For test points where \( k = 1 \), before processing every event the actual parameters \( l, r, h \) are obtained by taking the bitwise XOR of the given values with lastans. Here, lastans is defined as the answer of the most recent query (Type 1) event, and is \( 0 \) if no query has yet been answered.
inputFormat
The first line contains three integers \( n, m, k \) where \( n \) is the number of segments, \( m \) is the number of events, and \( k \) is the mode indicator. If \( k = 1 \) then each event's parameters \( l, r, h \) are encoded: the actual parameters are obtained by taking the XOR of each given parameter with lastans (the answer from the last query, with an initial value of \( 0 \)).
Then \( m \) lines follow. Each line contains four integers: op, l, r, and h.
- If op = 1, this is a query: output the number of segments in \( [l, r] \) whose height is less than \( h \).
- If op = 2, for every segment in \( [l, r] \) with height greater than \( h \), set its height to \( h \).
- If op = 3, for every segment in \( [l, r] \) with height less than \( h \), set its height to \( h \).
Note: The indexing of segments is 1-based.
outputFormat
For each query event (where op = 1), output the corresponding answer on a new line.
sample
5 5 0
1 1 5 1
2 2 4 1
1 1 5 1
3 1 3 2
1 1 5 2
5
5
2
</p>