/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 81ms 680.0 KiB
#4 Accepted 106ms 2.859 MiB
#5 Accepted 108ms 4.035 MiB
#6 Accepted 60ms 572.0 KiB
#7 Accepted 61ms 584.0 KiB
#8 Accepted 60ms 580.0 KiB
#9 Accepted 122ms 4.355 MiB
#10 Accepted 23ms 412.0 KiB

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<long long,long long> PLL;

#define int long long
#define all(v) v.begin(),v.end()
#define faster {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}  

const LL mod = 1e9 + 7;
const int N = 2e5 + 10;
const LL inf = 1e9;

void solve(int test){
    int n; cin>>n;
    map<int, PLL> mp;
    LL ans = 0, x = 0; mp[0] = {1, 1};
    for(int i = 1; i <= n; i++){
        int u; cin>>u; x ^= u;
        auto [l, sum] = mp[x];
        ans += (1LL * l * i - sum); 
        mp[x].first++, mp[x].second += (i + 1);
    }
    cout<<ans<<'\n';
}

signed main(){
    faster
    int t = 1; 
    cin>>t;
    for(int i = 1; i <= t; i++){
        solve(i);
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1096 Mr. Heart and the XOR Puzzle
Contest
Brain Booster #6
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-03 16:50:40
Judged At
2024-12-17 11:33:54
Judged By
Score
100
Total Time
122ms
Peak Memory
4.355 MiB