Submission #1076372

# Submission time Handle Problem Language Result Execution time Memory
1076372 2024-08-26T13:24:03 Z vjudge1 XOR Sum (info1cup17_xorsum) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#ifndef ONLINE_JUDGE
#include "tdebug.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif

#define                int  long long
#define                pii  pair<int, int>
#define                 fi  first
#define                 se  second
#define                 ld  long double
#define                 vi  vector<int>
#define                vii  vector<vector<int>>
#define             all(v)  (v).begin(), (v).end()
#define       rep(i, a, b)  for (int i = (a), _b = (b); i <= _b; ++i)
#define       per(i, b, a)  for (int i = (b), _a = (a); i >= _a; --i)

using namespace std;

const int MOD = 1e9 + 7;

int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

int mul(int a, int b) {
  (a *= b) %= MOD;
  return a;
}

int bin_pow(int x, int y) {
  int res=1;
  while(y){if(y&1)res=res*x%MOD;x=x*x%MOD;y>>=1;}
  return res;
}

const int INF = 1e17;
const int maxn = 2e5 + 5;
const int LG = 29;

int N, ans;
int a[maxn + 5], c[maxn + 5];

void solve(int tc) {
  cin >> N;
  rep(i, 1, N) cin >> a[i];
  rep(j, 0, LG) {
    vi b0, b1;
    rep(i, 1, N) {
      if (a[i] & (1ll << j)) b1.push_back(a[i]);
      else b0.push_back(a[i]);
    }
    rep(i, 1, N) {
      if (i <= (int)b0.size()) {
        a[i] = b0[i - 1];
      } else {
        a[i] = b1[i - (int)b0.size() - 1];
      }
      c[i] = (a[i] & ((1ll << (j + 1)) - 1));
    }
    int pj = N, pk = N, pl = N;
    rep(i, 1, N) {
      pj = max(pj, i); pk = max(pk, i); pl = max(pl, i);
      while (pj >= i && c[i] + c[pj] >= (1ll << j)) pj--;
      while (pk >= i && c[i] + c[pk] >= (1ll << (j + 1))) pk--;
      while (pl >= i && c[i] + c[pl] >= (1ll << j) + (1ll << (j + 1))) pl--;
      if ((N - pl + pk - pj) & 1) ans ^= (1ll << j);
    }
  }
  cout << ans;
}

///  011
/// 1001
///  110
///  110

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  int tc = 1;
//  cin >> tc;
  for (int i = 1; i <= tc; ++i) {
    solve(i);
  }
}

Compilation message

xorsum.cpp:4:10: fatal error: tdebug.cpp: No such file or directory
    4 | #include "tdebug.cpp"
      |          ^~~~~~~~~~~~
compilation terminated.