Submission #67701

#TimeUsernameProblemLanguageResultExecution timeMemory
67701tatatanXOR Sum (info1cup17_xorsum)C++11
45 / 100
1666 ms8216 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; const int MAXN=1000005; int n,a[MAXN],b[MAXN],ans; int main() { scanf("%d",&n); for(int i=0;i<n;++i) scanf("%d",&a[i]); for(int i=0;i<30;++i) { int xo=(1<<(i+1))-1,t1,t2,t3; LL cnt=0; for(int j=0;j<n;++j) { b[j]=xo&a[j]; } sort(b,b+n); t1=t2=t3=n; for(int j=0;j<n;++j) { while(t1&&b[t1-1]>=(1<<i)-b[j]) --t1; while(t2&&b[t2-1]>=(1<<(i+1))-b[j]) --t2; while(t3&&b[t3-1]>=(1<<(i+1))+(1<<i)-b[j]) --t3; cnt+=(n-t1-(t3-t2)); } for(int j=0;j<n;++j) if((b[j]*2)&(1<<i)) --cnt; cnt/=2; for(int j=0;j<n;++j) if((b[j]*2)&(1<<i)) ++cnt; if(cnt&1) ans+=(1<<i); } printf("%d\n",ans); }

Compilation message (stderr)

xorsum.cpp: In function 'int main()':
xorsum.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
#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...