제출 #884238

#제출 시각아이디문제언어결과실행 시간메모리
884238aykhnXOR Sum (info1cup17_xorsum)C++17
100 / 100
1024 ms39784 KiB
#include <bits/stdc++.h> // author : aykhn using namespace std; typedef long long ll; #define pb push_back #define ins insert #define mpr make_pair #define all(v) v.begin(), v.end() #define bpc __builtin_popcountll #define pii pair<ll, ll> #define pll pair<ll, ll> #define fi first #define se second #define int ll #define infll 0x3F3F3F3F3F3F3F3F #define inf 0x3F3F3F3F const int MXN = 1e5 + 5; signed main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int n; cin >> n; int a[n]; pii b[n]; for (int i = 0; i < n; i++) cin >> a[i], b[i] = mpr(0LL, i); int res = 0; for (int j = 0; j < 30; j++) { pii c[n]; int l = 0; int r = n - 1; for (int i = n - 1; i >= 0; i--) if (a[b[i].se] >> j & 1) c[r--] = {b[i].fi | (1 << j), b[i].se}; for (int i = 0; i < n; i++) if (!(a[b[i].se] >> j & 1)) c[l++] = b[i]; for (int i = 0; i < n; i++) b[i] = c[i]; int cnt = 0; int i1, i2, i3, i4; i1 = i2 = i3 = i4 = 0; for (int i = n - 1; i >= 0; i--) { while (i1 < n && b[i1].fi < (1 << j) - b[i].fi) i1++; while (i2 < n && b[i2].fi < (1 << (j + 1)) - b[i].fi) i2++; while (i3 < n && b[i3].fi < ((1 << (j + 1)) | (1 << j)) - b[i].fi) i3++; while (i4 < n && b[i4].fi < (1 << (j + 2)) - b[i].fi) i4++; if (max(i1, i) < i2) cnt += i2 - max(i1, i); if (max(i3, i) < i4) cnt += i4 - max(i3, i); } if (cnt & 1) res |= (1 << j); } cout << res << '\n'; } // ignore (i + 1 -> 23]; // a[i] &= (1 << (i + 1)) - 1; // (1 << i) <= a[i] + a[j] < (1 << (i + 1)); // (1 << (i + 1)) | (1 << i) <= a[i] + a[j] < (1 << (i + 2))
#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...