#P4462. [CQOI2018] 异或序列

    ID: 5186 远端评测题 1000ms 500MiB 尝试: 75 已通过: 2 显示难度提高 上传者: 标签>2018重庆莫队各省省选进制前缀和

[CQOI2018] 异或序列

Problem 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 (l≤x≤y≤r)(l \leq x \leq y \leq r), how many pairs (x,y)(x, y) satisfy ax⊕ax+1⊕⋯⊕ay=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, 1≤n,m≤10001 \leq n, m \leq 1000.

For 100%100\% of the testdata, 1≤n,m≤1051 \leq n, m \leq 10^5, 0≤k,ai≤1050 \leq k, a_i \leq 10^5, 1≤lj≤rj≤n1 \leq l_j \leq r_j \leq n.

Translated by ChatGPT 5