#P4462. [CQOI2018] 异或序列

    ID: 3391 远端评测题 1000ms 500MiB 尝试: 5 已通过: 1 难度: 7 上传者: 标签>2018重庆莫队线段树各省省选进制前缀和

[CQOI2018] 异或序列

Description

Given an integer sequence a1,a2,,ana_1, a_2, \dots, a_n of length nn, for a query with parameters l,rl, r, ask how many subarrays within al,al+1,,ara_l, a_{l+1}, \dots, a_r have xor-sum equal to kk. That is, among all x,yx, y such that (lxyr)(l \leq x \leq y \leq r), how many pairs (x,y)(x, y) satisfy axax+1ay=ka_x \oplus a_{x+1} \oplus \dots \oplus a_y = k.

Input Format

The first line contains three integers n,m,kn, m, k.

The second line contains nn integers separated by spaces, namely a1,a2,,ana_1, a_2, \dots, a_n.

Each of the next mm lines contains two integers ljl_j and rjr_j, representing one query.

Output Format

Output mm lines, each corresponding to the answer for one query.

4 5 1
1 2 3 1
1 4
1 3
2 3
2 4
4 4
4
2
1
2
1

Hint

For 30%30\% of the testdata, 1n,m10001 \leq n, m \leq 1000.

For 100%100\% of the testdata, 1n,m1051 \leq n, m \leq 10^5, 0k,ai1050 \leq k, a_i \leq 10^5, 1ljrjn1 \leq l_j \leq r_j \leq n.

Translated by ChatGPT 5