#P4560. Sequence Height Operations
Sequence Height Operations
Sequence Height Operations
Given a sequence of length \( n \) initially filled with \( 0 \), you need to support the following two operations:
- Add \( L, R, h \): For each element in the segment \( [L, R] \) that is less than \( h \), set it to \( h \) (elements with values greater than or equal to \( h \) remain unchanged).
- Remove \( L, R, h \): For each element in the segment \( [L, R] \) that is greater than \( h \), set it to \( h \) (elements with values less than or equal to \( h \) remain unchanged).
After performing \( k \) operations, output the final state of the sequence.
inputFormat
The first line contains two integers \( n \) and \( k \) \( (1 \le n, k \le 10^5) \) representing the length of the sequence and the number of operations.
Each of the following \( k \) lines describes an operation in one of the following formats:
Add L R h
Remove L R h
Note: The sequence is 1-indexed.
outputFormat
Output the final state of the sequence as \( n \) space-separated integers on a single line.
sample
5 3
Add 1 3 5
Add 2 5 3
Remove 3 4 4
5 5 4 3 3