#P5586. [P5350] 序列 (加强版)

    ID: 4546 远端评测题 3000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>平衡树洛谷原创O2优化可持久化

[P5350] 序列 (加强版)

Description

There is a sequence ana_n and qq operations.

  • 1 l r Query the sum of the interval [l,r][l,r].
  • 2 l r k Assign all values in the interval [l,r][l,r] to kk.
  • 3 l r k Add kk to all values in the interval [l,r][l,r].
  • 4 l1 r1 l2 r2 Copy the interval [l1,r1][l_1,r_1] to [l2,r2][l_2,r_2].
  • 5 l1 r1 l2 r2 Swap the intervals [l1,r1][l_1,r_1] and [l2,r2][l_2,r_2].
  • 6 l r Reverse the interval [l,r][l,r].

In the end, you also need to output the entire sequence. All outputs should be taken modulo 109+710^9+7.

To block some brute-force or hacky solutions, this problem is strictly online.

In each operation, except for the first number, all other numbers must be XORed with last\text{last} to obtain the actual operation.
last\text{last} is the answer of the previous type 11 operation (mod109+7)\pmod{10^9 + 7}, and initially last=0\text{last} = 0.

Input Format

The first line contains two positive integers n,qn,q, representing the sequence length and the number of operations.
The second line contains nn positive integers, representing the sequence aa.
The next qq lines each describe one operation.

Output Format

For each type 11 operation, output one integer per line as the answer.
In the last line, output nn integers, representing the final sequence aa.

10 10
7 1 3 2 2 4 0 1 2 2 
4 10 10 3 3
3 4 10 5
6 6 7
6 9 10
1 10 10
5 14 13 1 0
2 15 13 7
5 3 3 2 2
5 5 3 15 13
3 4 14 7
7
7 0 0 0 7 7 7 1 2 7

Hint

Constraints
1n,q3×1051\le n,q \le 3\times 10^5
0ai,k1090\le a_i,k \le 10^9
For operations 44 and 55, it is guaranteed that r1l1=r2l2r_1-l_1 = r_2-l_2 and [l1,r1][l2,r2]=[l_1,r_1] \cap [l_2,r_2] = \varnothing.

The testdata is not guaranteed to be random, and there is no grading by subtasks.
If you want to submit ODT, just forget it.

Translated by ChatGPT 5