想不到 AC 了,是我太菜了吗。。。
贴个代码,求大佬解释。宏定义别骂awa。
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i = (l),SIZE = (r);i <= SIZE;i++)
#define per(i,l,r) for (int i = (l),SIZE = (r);i >= SIZE;i--)
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef pair <int,int> PII;
const int N = 100010,M = 1 << 20;
int n;
int a[N];
int s[N];
int cnt[M];
int main () {
cin >> n;
rep (i,1,n) cin >> a[i],s[i] = s[i - 1] ^ a[i];
LL ans = 0;
cnt[0] = 1;
rep (i,1,n) ans += cnt[s[i]],cnt[s[i]]++;
rep (i,0,M - 1) cnt[i] = 0;
cout << ans << endl;
return 0;
}