#P8937. [JRKSJ R7] 五彩斑斓的曙光

[JRKSJ R7] 五彩斑斓的曙光

Background

The problem name was provided by fjy666, background TBD.

Problem Description

You are given a sequence aa of length nn. Please support mm operations:

  1. Subtract xx from the numbers >x> x in the interval [l,r][l,r].
  2. Query the count of numbers x\le x in the interval [l,r][l,r].

Input Format

This problem is strictly online.

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

The second line contains nn integers representing aa.

The next mm lines each contain four integers opt,l,r,xopt,l,r,x', where optopt is the operation type. The real xx is obtained by taking xx' XOR the answer of the most recent operation 22. If there has been no operation 22 before, then no XOR is needed, and the real xx is simply xx'.

Output Format

For every operation 22, output one integer per line as the answer.

10 10
20 10 20 14 4 15 11 20 2 13 
2 5 9 1
1 7 8 2
1 2 3 8
1 4 6 12
2 1 7 9
2 2 7 20
2 3 9 4
2 8 9 7
1 3 10 0
2 8 9 7
0
5
6
2
1
1
5 5
6 10 3 4 7 
1 1 3 3
1 3 4 3
2 3 5 3
1 1 3 11
2 2 3 5
2
2

Hint

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

Sample Explanation

Sample 11 before encryption:

10 10
20 10 20 14 4 15 11 20 2 13
2 5 9 1
1 7 8 2
1 2 3 8
1 4 6 12
2 1 7 9
2 2 7 17
2 3 9 2
2 8 9 5
1 3 10 1
2 8 9 6

Sample 22 before encryption:

5 5
6 10 3 4 7
1 1 3 3
1 3 4 3
2 3 5 3
1 1 3 9
2 2 3 7

Constraints

This problem uses bundled testdata.

Subtask\text{Subtask} nn\le mm\le Score\text{Score} Time Limit
11 10410^4 1010 1s\text{1s}
22 3×1053\times 10^5 3030 5s\text{5s}
33 7×1057\times 10^5 5×1055\times 10^5 6060 20s\text{20s}

For 100%100\% of the testdata, 1n7×1051\le n \le 7\times 10^5, 1m5×1051\le m\le 5\times 10^5, 1ai,x1091\le a_i,x\le 10^9, and 1lrn1\le l\le r\le n.

Hint

If you believe your algorithm has the correct time complexity but the constant factor is too large, you may use an algorithm with the same idea, slightly worse time complexity, but a smaller constant factor.

Translated by ChatGPT 5