Wall
Time limit3sMemory limit256 MB
Apply k range raise-to-at-least and lower-to-at-most updates on n columns and print each final height.
- Level
Hard8 of 10
- Topics
- Segment tree
- Solved
- No attempts yet
Problem
Gianina builds a wall of columns of equal bricks. Columns are numbered through from left to right. The height of a column is its brick count.
Initially every column has height 0. Over steps, each step gives an inclusive column range and a height .
- Add (op=1): within the range, any column shorter than receives bricks until its height is exactly . Columns already at least stay unchanged.
- Remove (op=2): within the range, any column taller than loses bricks until its height is exactly . Columns already at most stay unchanged.
After all steps, output the final brick count in each column.
Input
Line 1: , .
Next lines: op left right height
op=1add,op=2removeleft,right: inclusive range ()height: target height
Output
Print the final brick count of each column, one per line from left to right.