-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path617E.cpp
More file actions
75 lines (70 loc) · 1.14 KB
/
Copy path617E.cpp
File metadata and controls
75 lines (70 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, k;
int xo[100009], a[100009];
ll ans[100009];
ll cnt[1 << 20];
ll res;
struct query{
int x, y, list;
int xk, yk;
}q[100009];
bool cmp(const query &a, const query &b){
if(a.yk != b.yk) return a.yk < b.yk;
if(a.yk % 2 == 1) return a.xk > b.xk;
return a.xk < b.xk;
}
void add(int x){
res += cnt[x ^ k];
cnt[x]++;
}
void del(int x){
cnt[x]--;
res -= cnt[x ^ k];
}
int main(){
scanf("%d%d%d", &n, &m, &k);
for(int i = 1; i <= n; i++){
scanf("%d", &a[i]);
}
for(int i = 1; i <= n; i++){
xo[i] = xo[i - 1] ^ a[i];
}
int t = sqrt(n);
for(int i = 1; i <= m; i++){
int x, y;
scanf("%d%d", &x, &y);
x--;
q[i].x = x, q[i].y = y;
q[i].list = i;
q[i].xk = x / t;
q[i].yk = y / t;
}
sort(q + 1, q + m + 1, cmp);
int l = 1, r = 1;
add(xo[l]);
for(int i = 1; i <= m; i++){
int x = q[i].x, y = q[i].y;
while(r < y){
r++;
add(xo[r]);
}
while(l < x){
del(xo[l]);
l++;
}
while(r > y){
del(xo[r]);
r--;
}
while(l > x){
l--;
add(xo[l]);
}
ans[q[i].list] = res;
}
for(int i = 1; i <= m; i++){
printf("%lld\n", ans[i]);
}
}