#P10081. [GDKOI2024 提高组] 新本格魔法少女

[GDKOI2024 提高组] 新本格魔法少女

Problem Description

You are given an integer sequence a1,,ana_1, \dots, a_n of length nn.

You are given an operation sequence consisting of mm operations, numbered from 11 to mm. The sequence contains assignment operations and range sum operations. An assignment operation gives l,r,vl, r, v, and sets al,al+1,,ara_l, a_{l+1}, \dots, a_r to vv. A range sum operation gives l,rl, r, and queries i=lrai\sum \limits_{i=l}^r a_i.

There are qq queries. Each query gives L,RL, R, asking for the sum of answers of all range sum operations when you initialize the sequence aa to 00, then apply the LL-th, (L+1)(L+1)-th, \dots, RR-th operations in order.

Input Format

The first line contains three integers n,m,qn, m, q.

The next mm lines each describe one operation in the form 1,l,r,v1, l, r, v or 2,l,r2, l, r.

The next qq lines each contain two integers L,RL, R, describing one query.

Output Format

Output qq lines. Each line contains one integer, the answer to each query in order.

10 5 4
1 9 10 7
1 7 10 9
2 3 10
1 10 10 1
2 5 10
2 5
1 1
3 4
1 3
64
0
0
36

Hint

For all testdata, 1lrn1 \leq l \leq r \leq n, 1vn1 \leq v \leq n, 1LRm1 \leq L \leq R \leq m, and 1n,m,q5×1051 \leq n, m, q \leq 5 \times 10^5.

For 10%10\% of the testdata, n,m,q102n, m, q \leq 10^2.

For another 20%20\% of the testdata, n,m,q5×103n, m, q \leq 5 \times 10^3.

For another 10%10\% of the testdata, every operation is a range sum operation.

For another 20%20\% of the testdata, every query satisfies L=1L = 1.

For another 20%20\% of the testdata, n,m,q2×105n, m, q \leq 2 \times 10^5.

For the remaining testdata, there are no special constraints.

Translated by ChatGPT 5