#P6707. [COCI 2010/2011 #7] UPIT

    ID: 5662 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2011平衡树块状链表,块状数组,分块COCI

[COCI 2010/2011 #7] UPIT

Description

Given a sequence ff, the following operations are supported.

Let the current length of the sequence be nn.

Query type Description
1 A B X fi=X(AiB)f_i = X (A \le i \le B).
2 A B X fi+=(iA+1)×X(AiB)f_i += (i - A + 1) \times X (A \le i \le B).
3 C X fi+1=fi(Cin)f_{i+1} = f_i (C \le i \le n), fC=Xf_C = X.
4 A B Compute i=ABfi\sum^B_{i=A} f_i.

Input Format

The first line contains two positive integers nn and QQ, representing the initial length of the sequence and the number of operations.

The second line contains nn non-negative integers, representing the initial sequence.

The next QQ lines each contain one query as described above.

Output Format

For each type 44 operation, output one line with the answer.

5 5
1 2 3 4 5
1 5 5 0
4 4 5
4 5 5
2 1 5 1
4 1 5
4
0
25
1 7
100
3 1 17
3 2 27
3 4 37
4 1 1
4 2 2
4 3 3
4 4 4
17
27
100
37

Hint

Constraints

Let the current sequence length be tt.

For 100%100\% of the testdata: 1n,Q1×1051 \le n, Q \le 1 \times 10^5, fi1×105f_i \le 1 \times 10^5, 1X1001 \le X \le 100, 1ABt1 \le A \le B \le t, 1Ct+11 \le C \le t + 1.

Notes

This problem is worth 130130 points in total.

Translated from COCI2010-2011 CONTEST #7 T6 UPIT.

Translated by ChatGPT 5