Submission #635904

# Submission time Handle Problem Language Result Execution time Memory
635904 2022-08-27T10:46:59 Z Dec0Dedd XOR Sum (info1cup17_xorsum) C++14
0 / 100
597 ms 13080 KB
#include <bits/stdc++.h>

using namespace std;

int ans;

int main() {
   int n; cin>>n;
   vector<int> v;
   for (int i=0; i<n; ++i) {
      int a; cin>>a;
      v.push_back(a);
   }

   for (int b=0; b<29; ++b) {
      vector<int> lf, rf;
      for (auto u : v) {
         if (u&(1<<b)) rf.push_back(u);
         else lf.push_back(u);
      }
      v.clear();
      for (auto u : lf) v.push_back(u);
      for (auto u : rf) v.push_back(u);

      int tmp=0, l=n-1, r=n-1, val=(1<<(b+1))-1, lb=1<<b, ub=(1<<(b+1))-1;
      for (int i=0; i<n; ++i) {
         while (l >= 0 && (v[i]&val)+(v[l]&val) >= lb) --l;
         while (r >= 0 && (v[i]&val)+(v[r]&val) > ub) --r;
         (tmp+=max(0, r-l+1))%=2;
      }

      l=n-1, r=n-1, lb=(1<<(b+1))+(1<<b), ub=(1<<(b+2))-2;
      for (int i=0; i<n; ++i) {
         while (l >= 0 && (v[i]&val)+(v[l]&val) >= lb) --l;
         while (r >= 0 && (v[i]&val)+(v[r&val]) > ub) --r;
         (tmp+=max(0, r-l+1))%=2;
      }

      if (tmp) ans^=1<<b;
   }
   cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 597 ms 13080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 597 ms 13080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -