Submission #1149592

#TimeUsernameProblemLanguageResultExecution timeMemory
1149592gazizmadi11XOR Sum (info1cup17_xorsum)C++20
56 / 100
1695 ms16088 KiB
//gm  --- akezhon
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define tm (tl+tr)/2
#define TL v+v, tl, tm
#define TR v+v+1, tm+1, tr
#define DA l <= tl && tr <= r
#define NE r < tl || tr < l
#define double long double
#define int long long 
using namespace std;

const int N=1e5+7;
const int mod=998244353;
const int inf=2e18;

void AlemAmenov(){
    int n;
    cin >> n;
    int a[n+1];
    int b[n+1];
    for(int i=1; i <= n; i++){
        cin >> a[i];
    } 
    int ans=0;
    for(int k=0; k < 30; k++){
        for(int i=1; i <= n; i++){
            b[i] = a[i] & ((1<<(k+1))-1);
        }
        sort(b+1, b+1+n);
        int c=0, l1=n, r=n, l2=n;    
        int x1=(1<<k);
        int x2=(1<<(k+1))-1;
        int x3=(1<<(k+1))+(1<<k);
        for(int i=1; i <= n; i++){
            while(l1 && x1 <= b[i]+b[l1])l1--;
            while(r && x2 < b[i]+b[r])r--;
            while(l2 && x3 <= b[i]+b[l2])l2--;
            if(i <= l1+1)c += r-l1 + n-l2;
            else if(i <= r)c += r-i+1 + n-l2;
            else if(i <= l2+1)c += n-l2;
            else c += n-i+1;
        }
        if(c&1)ans+=(1<<k);
    }
    cout << ans;
}
signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int RealName=1;
    // cin >> RealName;

    // freopen("connect.in", "r", stdin);
    // freopen("connect.out", "w", stdout);

    while(RealName--)
        AlemAmenov();
    
return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...