#C785. Paint Fences
Paint Fences
Paint Fences
You are given N fences with initial heights and Q painting operations.
For each operation given by three integers \(L\), \(R\), and \(H\), you need to update the fences from index \(L\) to \(R\) (1-indexed) by setting their height to \(H\). Formally, for every fence index \(i\) with \(L \le i \le R\), update \(\text{heights}[i] = H\).
Your task is to compute the final heights of all fences after performing all the painting operations.
inputFormat
The input is given in the following format:
- The first line contains two integers \(N\) and \(Q\), where \(N\) is the number of fences and \(Q\) is the number of operations.
- The second line contains \(N\) integers representing the initial heights of the fences.
- Each of the next \(Q\) lines contains three integers \(L\), \(R\), and \(H\), defining a painting operation that sets the height of fences from index \(L\) to \(R\) (inclusive) to \(H\).
outputFormat
Output a single line containing \(N\) integers separated by spaces. These integers represent the final heights of the fences after applying all operations.
## sample5 1
1 2 3 4 5
1 3 7
7 7 7 4 5