#P10638. Array Maintenance Operations
Array Maintenance Operations
Array Maintenance Operations
You are given an integer sequence \(a\) of length \(n\). You need to support the following three types of operations:
- Operation 1: 1 u v c. For all \(i\) in \([u,v]\), set \(a_i=c\).
- Operation 2: 2 u v c. For all \(i\) in \([u,v]\), update \(a_i = \max(a_i+c, 0)\).
- Operation 3: 3 u v. Output the value of \(\sum_{i=u}^{v}[a_i=0]\), i.e. count the number of indices in \([u,v]\) for which \(a_i=0\).
You are given the initial sequence followed by \(m\) operations. Process the operations in order.
inputFormat
The first line contains two integers \(n\) and \(m\) \( (1 \leq n, m \leq \text{some limit})\), representing the length of the sequence and the number of operations respectively.
The second line contains \(n\) space-separated integers \(a_1, a_2, \dots, a_n\) which represent the initial array.
Each of the next \(m\) lines describes one operation in one of the following formats:
1 u v c
2 u v c
3 u v
outputFormat
For each operation of type 3, output a single line with one integer: the count of zeros in the specified segment.
sample
5 5
0 1 2 3 4
3 1 5
2 1 3 -1
3 1 3
1 4 5 0
3 1 5
1
2
4
</p>