답안 #635907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
635907 2022-08-27T11:03:44 Z Dec0Dedd XOR Sum (info1cup17_xorsum) C++14
100 / 100
1036 ms 13336 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<30; ++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);

      long long val=(1ll<<(b+1))-1, lb=1ll<<b, ub=(1ll<<(b+1))-1;
      int tmp=0, l=n-1, r=n-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-max(l, i-1))))%=2;
      }

      l=n-1, r=n-1, lb=(1ll<<(b+1))+(1ll<<b), ub=(1ll<<(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-max(l, i-1)))%=2;
      }

      if (tmp) ans^=1<<b;
   }
   cout<<ans<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 650 ms 13256 KB Output is correct
2 Correct 598 ms 11780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 650 ms 13256 KB Output is correct
2 Correct 598 ms 11780 KB Output is correct
3 Correct 791 ms 12844 KB Output is correct
4 Correct 747 ms 12812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 106 ms 1592 KB Output is correct
4 Correct 107 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 340 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 650 ms 13256 KB Output is correct
4 Correct 598 ms 11780 KB Output is correct
5 Correct 791 ms 12844 KB Output is correct
6 Correct 747 ms 12812 KB Output is correct
7 Correct 106 ms 1592 KB Output is correct
8 Correct 107 ms 1612 KB Output is correct
9 Correct 1018 ms 13224 KB Output is correct
10 Correct 1036 ms 13240 KB Output is correct
11 Correct 1000 ms 13336 KB Output is correct