Submission #1149596

#TimeUsernameProblemLanguageResultExecution timeMemory
1149596gazizmadi11XOR Sum (info1cup17_xorsum)C++20
100 / 100
725 ms48592 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]; vector <pii> b, c; b.pb({0, 0}); for(int i=1; i <= n; i++){ cin >> a[i]; b.pb({0, a[i]}); } int ans=0; for(int k=0; k < 30; k++){ c.clear(); c.pb({0,0}); for(int i=1; i <= n; i++){ if(((1<<k)&b[i].S)==0)c.pb(b[i]); } for(int i=1; i <= n; i++){ if((1<<k)&b[i].S)c.pb({b[i].F+(1<<k), b[i].S}); } swap(b, c); 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].F+b[l1].F)l1--; while(r && x2 < b[i].F+b[r].F)r--; while(l2 && x3 <= b[i].F+b[l2].F)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...