#P6794. [SNOI2020] 水池
[SNOI2020] 水池
Description
There is a long, narrow pool that can be divided into cells. Cell and cell are adjacent, separated by an adjustable barrier with height . To the left of cell and to the right of cell are infinitely high pool walls. Initially, there is no water in the pool.
Now perform operations. There are four types of operations:
0 i x h: Pour water into cell until the water surface height in that cell is not less than (if the current water surface height is already at least , nothing happens).1 i x: Open the drain at the bottom of cell until the water in that cell is completely drained, then close the drain.2 i x h: Increase the height of the barrier to the right of cell to (do not change existing water levels; it is guaranteed that the barrier height will not decrease).3 i x: Query the water surface height in cell .
Here, means that this operation is based on the state after the -th operation; means it is based on the initial state. In other words, the operations need to be persistent.
Input Format
The first line contains two non-negative integers , representing the number of cells in the pool and the number of operations.
The next line contains positive integers , representing the initial heights of the barriers.
Then follow lines, each describing one operation.
Output Format
For each operation of type 3, output one line with one integer representing the answer.
4 9
1 3 2
0 0 4 2
3 1 1
0 2 4 3
3 3 1
0 4 4 4
3 5 1
2 6 1 4
1 7 4
3 8 1
0
0
4
4
Hint
Sample Explanation
For sample :

Constraints
For all testdata, , .
- For of the testdata, .
- For another , there is no operation
1, and increases consecutively starting from (persistence is not needed). - For another , there is no operation
1. - For another , and increases consecutively starting from (persistence is not needed).
- For the remaining of the testdata, there are no special restrictions.
Translated by ChatGPT 5
京公网安备 11011102002149号