#P5612. [Ynoi2013] Ynoi

[Ynoi2013] Ynoi

Problem Description

Maintain a sequence a1,a2,a3,,ana_1,a_2,a_3,\ldots,a_n consisting of nn non-negative integers, and support three operations:

  1. Given an interval [l,r][l,r], apply XOR with xx to every number in this interval.
  2. Given an interval [l,r][l,r], sort the numbers in this interval in non-decreasing order.
  3. Given an interval [l,r][l,r], compute the XOR sum of the numbers in this interval.

Input Format

The first line contains two integers n,mn,m.

The second line contains nn integers aia_i, representing the original sequence.

The next mm lines describe the operations. Each line contains three integers opt,l,ropt,l,r (opt{2,3}opt\in\{2,3\}), or four integers opt,l,r,xopt,l,r,x (opt=1opt=1), representing the corresponding operation.

Output Format

For each operation 33, output one line with the corresponding answer.

5 3
1 4 2 8 3
2 1 3
1 2 4 5
3 1 2
6

Hint

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

Sample Explanation

The original sequence is 1 4 2 8 31\ 4\ 2\ 8\ 3.

Sort the interval [1,3][1,3], getting [1 2 4] 8 3[1\ 2\ 4]\ 8\ 3.

Apply bitwise XOR with 55 to the interval [2,4][2,4]: 2 xor 5=72\ \mathrm{xor}\ 5 = 7, 4 xor 5=14\ \mathrm{xor}\ 5 = 1, 8 xor 5=138\ \mathrm{xor}\ 5 = 13, getting 1 [7 1 13] 31\ [7\ 1\ 13]\ 3.

Query the XOR sum of the interval [1,2][1,2]: [1 7] 1 13 3[1\ 7]\ 1\ 13\ 3, 1 xor 7=61\ \mathrm{xor}\ 7 = 6.

Constraints

1n,m1051 \le n,m \le 10^5, 0ai,x<1080 \le a_i,x<10^8

Translated by ChatGPT 5