根据异或满足消去律可推出sum[ r ] = sum[ l - 1] 且数组长度为偶数的均满足
#define int ll
int a[MAXN],sum[MAXN];
void solve()
{
int n;cin>>n;
rpp(i,n)
{
cin>>a[i];
sum[i]=sum[i-1]^a[i];
}
map<int,int>mp[2];
++mp[0][0],++mp[1][sum[1]];
int ans=0;
for(int i=2;i<=n;++i)
{
ans+=mp[i%2][sum[i]];
++mp[i%2][sum[i]];
}
cout<<ans<<endl;
}
signed main()
{
int T = 1;
while (T--) solve();
return 0;
}
来源:CSDN
作者:咖啡店老板娘
链接:https://blog.csdn.net/weixin_44116061/article/details/104608208