#C431. Array Query Processing

    ID: 47834 Type: Default 1000ms 256MiB

Array Query Processing

Array Query Processing

You are given an array A of N integers and Q queries. Each query is one of the following two types:

  • Type 1: Given four integers 1, L, R, X, add X to every element in the subarray A[L...R].
  • Type 2: Given four integers 2, L, R, X, for every element in the subarray A[L...R], replace it with \( \max(A[i], X) \).

Note that the array is 1-indexed. After processing all the queries sequentially, output the final state of the array.

Input Format: All input is read from stdin and output should be written to stdout.

inputFormat

The first line of input contains an integer N representing the number of elements in the array.

The second line contains N space separated integers representing the array A.

The third line contains an integer Q representing the number of queries.

Each of the next Q lines contains four space separated integers: type, L, R, X, describing a query.

outputFormat

After processing all queries, output the final state of the array as N space separated integers on a single line.

## sample
5
3 1 4 1 5
3
1 1 3 2
2 2 5 4
1 1 5 1
6 5 7 5 6

</p>