#P1253. 扶苏的问题

扶苏的问题

Description

Given a sequence aa of length nn, support the following three operations:

  1. Given a range [l,r][l, r], set every number in the range to xx.
  2. Given a range [l,r][l, r], add xx to every number in the range.
  3. Given a range [l,r][l, r], query the maximum value in the range.

Input Format

The first line contains two integers, the length of the sequence nn and the number of operations qq.
The second line contains nn integers, where the ii-th integer is the ii-th number aia_i in the sequence.
Then follow qq lines, each representing an operation. Each line starts with an integer opop indicating the type of operation.

  • If op=1op = 1, then there are three integers l,r,xl, r, x, meaning set every number in the range [l,r][l, r] to xx.
  • If op=2op = 2, then there are three integers l,r,xl, r, x, meaning add xx to every number in the range [l,r][l, r].
  • If op=3op = 3, then there are two integers l,rl, r, meaning query the maximum value in the range [l,r][l, r].

Output Format

For each operation with op=3op = 3, output one line with a single integer representing the answer.

6 6
1 1 4 5 1 4
1 1 2 6
2 3 4 2
3 1 4
3 2 3
1 1 6 -1
3 1 6

7
6
-1
4 4
10 4 -3 -7
1 1 3 0
2 3 4 -4
1 2 4 -9
3 1 4
0

Hint

Constraints

  • For 10%10\% of the testdata, n=q=1n = q = 1.
  • For 40%40\% of the testdata, n,q103n, q \leq 10^3.
  • For 50%50\% of the testdata, 0ai,x1040 \leq a_i, x \leq 10^4.
  • For 60%60\% of the testdata, op1op \neq 1.
  • For 90%90\% of the testdata, n,q105n, q \leq 10^5.
  • For 100%100\% of the testdata, 1n,q1061 \leq n, q \leq 10^6, 1l,rn1 \leq l, r \leq n, op{1,2,3}op \in \{1, 2, 3\}, ai,x109|a_i|, |x| \leq 10^9.

Please note the impact of large input on program efficiency.

Translated by ChatGPT 5