#P10638. BZOJ4355 Play with sequence

    ID: 12112 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>线段树O2优化吉司机线段树 segment tree beats

BZOJ4355 Play with sequence

Problem Description

Maintain an integer sequence aa of length nn, supporting three operations:

  • 1 u v c: for i[u,v]\forall i \in [u,v], change aia_i to cc.
  • 2 u v c: for i[u,v]\forall i \in [u,v], change aia_i to max(ai+c,0)\max(a_i+c,0).
  • 3 u v: output the value of i=uv[ai=0]\sum \limits_{i=u}^v [a_i=0].

Input Format

The first line contains two positive integers n,mn,m, representing the sequence length and the number of operations.

The second line contains nn integers aia_i, representing the initial state of the sequence.

Starting from the third line, the next mm lines each describe one operation.

Output Format

Output several lines, one integer per line, answering each operation 33 in order.

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

Hint

For 100%100\% of the testdata, 1n,m3×1051\leq n,m\leq 3\times 10^5, 0ai1090\leq a_i\leq 10^9.

  • For operation 11, it is guaranteed that 0c1090\leq c\leq 10^9.
  • For operation 22, it is guaranteed that c109|c| \leq 10^9.

For all operations, it is guaranteed that 1uvn1\leq u\leq v\leq n.

Translated by ChatGPT 5