思路:首先题意转化为求一段偶数长度的区间的异或和为0.观察可以发现最多二十位所以用一个数组记录该数出现的次数,因为长度为偶数所以起点和终点奇偶性不同。利用cnt[2][]去记录即可。
/*keep on going and never give up*/
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
typedef pair<int, int> pii;
#define int long long
#define lowbit(x) x&(-x)
#define endl '\n'
#define wk is zqx ta die
int ans = 0;
int cnt[2][(1 << 20) + 100];
int sum;
int a[300006];
signed main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
cnt[0][0] = 1;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum = sum ^ a[i];
ans += cnt[(i % 2)][sum];
cnt[(i % 2)][sum]++;
// cout << ans << endl;
}
cout << ans << endl;
return 0;
}