#P8526. [Ynoi2078] 《How to represent part-whole hierarchies in a neural network》阅读报告(更新中...)

[Ynoi2078] 《How to represent part-whole hierarchies in a neural network》阅读报告(更新中...)

Problem Description

Given a sequence a1,,ana_1,\dots,a_n and mm queries. Each query gives 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

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

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

5 2
1 1 1 2 4
1 5
3 5

3
2

Hint

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

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.

Constraints: 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.

Translated by ChatGPT 5