思路
CODE
1 #include <bits/stdc++.h> 2 #define dbg(x) cout << #x << "=" << x << endl 3 4 using namespace std; 5 typedef long long LL; 6 7 template<class T>inline void read(T &res) 8 { 9 char c;T flag=1; 10 while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0'; 11 while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag; 12 } 13 14 namespace _buff { 15 const size_t BUFF = 1 << 19; 16 char ibuf[BUFF], *ib = ibuf, *ie = ibuf; 17 char getc() { 18 if (ib == ie) { 19 ib = ibuf; 20 ie = ibuf + fread(ibuf, 1, BUFF, stdin); 21 } 22 return ib == ie ? -1 : *ib++; 23 } 24 } 25 26 int qread() { 27 using namespace _buff; 28 int ret = 0; 29 bool pos = true; 30 char c = getc(); 31 for (; (c < '0' || c > '9') && c != '-'; c = getc()) { 32 assert(~c); 33 } 34 if (c == '-') { 35 pos = false; 36 c = getc(); 37 } 38 for (; c >= '0' && c <= '9'; c = getc()) { 39 ret = (ret << 3) + (ret << 1) + (c ^ 48); 40 } 41 return pos ? ret : -ret; 42 } 43 44 const int maxn = 2e5 + 7; 45 46 map <int, int> mapp; 47 int a[maxn]; 48 int n; 49 int xorsum[maxn]; 50 51 int main() 52 { 53 read(n); 54 for(int i = 1; i <= n; ++i) { 55 read(a[i]); 56 xorsum[i] = xorsum[i-1]; 57 xorsum[i] ^= a[i]; 58 } 59 mapp[0] = 1; 60 LL ans = 0; 61 62 for(int i = 1; i <= n; ++i) { 63 if(mapp[xorsum[i]]) { 64 ans += mapp[xorsum[i]]; 65 } 66 mapp[xorsum[i]]++; 67 } 68 cout << ans << endl; 69 return 0; 70 }