#P5524. [Ynoi2012] NOIP2015 充满了希望

[Ynoi2012] NOIP2015 充满了希望

Problem Description

You are given a sequence of length nn and mm operations, numbered from 11 to mm. Each operation is one of the following:

1 x y: Swap the two elements at positions xx and yy in the sequence.

2 l r x: Set all elements in the interval [l,r][l,r] of the sequence to xx.

3 x: Query the value at position xx in the sequence.

Now there are qq queries. Each query gives an operation interval [l,r][l,r]:

First set all elements in the sequence to 00, then perform all operations from ll to rr in order. Find the sum of the answers of all type 33 operations among these operations.

Queries are independent.

Input Format

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

Then follow mm lines. Each line contains 22 to 44 integers, describing an operation.

Then follow qq lines. Each line contains two integers l,rl,r, meaning that the operations in [l,r][l,r] are executed in order, and you need the sum of the answers of all type 33 operations.

Output Format

For each query, output one integer per line representing the answer.

5 10 6
3 1
3 5
2 5 5 10
3 1
2 5 5 5
3 5
3 1
1 1 5
2 5 5 3
3 5
5 6
3 6
1 10
2 8
3 10
7 8
5
5
8
5
8
0

Hint

Idea: nzhtl1477 & ccz181078, Solution: nzhtl1477 & ccz181078, Code: ccz181078, Data: ccz181078.

Constraints:

For 10%10\% of the testdata, 1n,m,q10001\le n,m,q\le 1000.

For 40%40\% of the testdata, 1n,m,q1051\le n,m,q\le 10^5.

For another 20%20\% of the testdata, there is no type 11 operation.

For another 20%20\% of the testdata, there is no type 22 operation.

For 100%100\% of the testdata, 1n,m,q1061\le n,m,q\le 10^6, 1x1091\le x\le 10^9.

Translated by ChatGPT 5