Submission #1076385

#TimeUsernameProblemLanguageResultExecution timeMemory
1076385LucasLeXOR Sum (info1cup17_xorsum)C++17
100 / 100
569 ms38352 KiB
#include <bits/stdc++.h> #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 = 2e6 + 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() { 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); } }
#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...