Submission #1313962

#TimeUsernameProblemLanguageResultExecution timeMemory
1313962ulvixXOR Sum (info1cup17_xorsum)C++20
56 / 100
1641 ms8180 KiB
#include <bits/stdc++.h> #ifdef ULVI #include "debug.hpp" #else #define db(...) #define dbv(v) #define line() #endif #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define ff first #define ss second #define enld endl using namespace std; using namespace __gnu_pbds; typedef int ll; typedef pair<ll,ll> pll; const ll sz=2e5+100; const ll lg=30; const ll mod=1e9+7; const ll inf=1e18; template<class T> using indexed_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve(){ ll n; cin>>n; vector<ll> v(n); for(ll i=0;i<n;i++) cin>>v[i]; ll ans=0; for(ll b=0;b<lg;b++){ ll pw=(1ll<<b); ll d=(pw+1)/2; vector<ll> a(n); ll cnt=0,cnt1=0; for(ll i=0;i<n;i++){ a[i]=v[i]&(pw-1); if(v[i]>>b&1) cnt1++; if(a[i]>=d) cnt++; } ll cnt0=n-cnt1,pt=0; sort(all(a)); for(ll i=n-1;i>=1;i--){ while(pt<i && a[pt]<pw-a[i]) pt++; if(pt<i) cnt=(cnt+i-pt)%2; else break; } cnt1%=2; cnt0%=2; cnt=(cnt+cnt0*cnt1)%2; if(cnt) ans+=pw; } cout<<ans<<'\n'; } int main(){ // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); ll t=1; // cin>>t; for(ll _=1;_<=t;_++){ // cout<<"Scenario #"<<_<<":\n"; solve(); } }

Compilation message (stderr)

xorsum.cpp:25:14: warning: overflow in conversion from 'double' to 'll' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   25 | const ll inf=1e18;
      |              ^~~~
#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...