Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lli long long int
  4. struct info{
  5. lli s, f;
  6. };
  7. lli a[100009];
  8. int main()
  9. {
  10. lli n,t;
  11. cin>>t;
  12. while(t--){
  13. map<lli,info> m;
  14. cin>>n;
  15. for(int i=0;i<n;++i){
  16. cin>>a[i];
  17. }
  18. m[0].s = 0;
  19. m[0].f = 1;
  20. lli x = 0;
  21. lli c = 0;
  22. for(int i=0;i<n;++i){
  23. x = x xor a[i];
  24. map<lli,info>::iterator itr = m.find(x);
  25. if(itr==m.end()){
  26. m[x].s = i+1;
  27. m[x].f = 1;
  28. }
  29. else{
  30. c += abs(m[x].s-m[x].f*i);
  31. m[x].s += i+1;
  32. m[x].f++;
  33. }
  34. }
  35. cout<<c<<endl;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement