#P8257. [CTS2022] 普罗霍洛夫卡

[CTS2022] 普罗霍洛夫卡

Problem Description

Given a sequence a1,,ana_1,\dots,a_n and a total of mm queries, each query provides l,rl,r. You need to compute the bitwise XOR sum of the weights of all pairs (L,R)(L,R) that satisfy lLRrl\le L\le R\le r. The weight of a pair (L,R)(L,R) is {aiLiR}|\{a_i\mid L\le i\le R\}|.

Input Format

Read from standard input.

The first line contains two integers n mn\ m.

The next line contains nn integers a1,,ana_1,\dots,a_n.

The next mm lines each contain two integers l rl\ r, representing one query.

Output Format

Write to standard output.

Output mm lines, in order, each being the answer to the corresponding query.

5 2
1 1 1 2 4
1 5
3 5

3
2

Hint

For 5%5\% of the testdata, 1n,m1001\le n,m\le 100.

For 10%10\% of the testdata, 1n,m50001\le n,m\le 5000.

For 20%20\% of the testdata, 1n,m1051\le n,m\le 10^5.

For 30%30\% of the testdata, 1n,m2×1051\le n,m\le 2\times 10^5.

For 40%40\% of the testdata, 1n,m3×1051\le n,m\le 3\times 10^5.

For 50%50\% of the testdata, 1n,m3.5×1051\le n,m\le 3.5\times 10^5.

For another 10%10\% of the testdata, m=n2m=n^2.

For another 10%10\% of the testdata, for all i=1ni=1\cdots n, ai2a_i\le 2.

For another 10%10\% of the testdata, for all i=1ni=1\cdots n, ai10a_i\le 10.

For 100%100\% of the testdata, 1n,m4×1051\le n,m\le 4\times 10^5, 1ain1\le a_i\le n, and all values are integers.

Each category of testdata forms a subtask.

Translated by ChatGPT 5