Submission #48395

#TimeUsernameProblemLanguageResultExecution timeMemory
48395PajarajaXOR Sum (info1cup17_xorsum)C++17
0 / 100
2 ms548 KiB
#include <bits/stdc++.h> using namespace std; int a[1000007],c[1000007]; int main() { int n,sol=0; freopen("tc.txt","r",stdin); freopen("out.txt","w",stdout); scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int j=0;j<30;j++) { int b=(1<<j),bc=0; for(int i=1;i<=n;i++) c[i]=a[i]%b; for(int i=1;i<=n;i++) if((a[i] | b) == a[i]) bc++; long long k=2*bc*(n-bc); sort(c+1,c+n+1); int t1=1,t2=n; while(t1<=n) { while(c[t2]+c[t1]>=b) t2--; k+=(n-t2); t1++; } for(int i=1;i<=n;i++) if(2*c[i]>=b) k++; if((k/2)%2==1) sol+=b; } printf("%d",sol); }

Compilation message (stderr)

xorsum.cpp: In function 'int main()':
xorsum.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("tc.txt","r",stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
xorsum.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("out.txt","w",stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
xorsum.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:11:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) 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...