Submission #884231

#TimeUsernameProblemLanguageResultExecution timeMemory
884231aykhnXOR Sum (info1cup17_xorsum)C++17
0 / 100
1644 ms20652 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]; for (int i = 0; i < n; i++) cin >> a[i]; int res = 0; for (int j = 0; j <= 25; j++) { int b[n]; for (int i = 0; i < n; i++) b[i] = (a[i] & (1 << (j + 1)) - 1); sort(b, b + n); int c = 0; for (int i = 0; i < n; i++) { int l = lower_bound(b, b + n, (1 << j) - b[i]) - b; int r = lower_bound(b, b + n, (1 << (j + 1)) - b[i]) - b; l = max(l, i); if (l < r) c += r - l; l = lower_bound(b, b + n, ((1 << (j + 1)) | (1 << j)) - b[i]) - b; r = lower_bound(b, b + n, (1 << (j + 2)) - b[i]) - b; l = max(l, i); if (l < r) c += r - l; } if (c & 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))

Compilation message (stderr)

xorsum.cpp: In function 'int main()':
xorsum.cpp:35:67: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   35 |         for (int i = 0; i < n; i++) b[i] = (a[i] & (1 << (j + 1)) - 1);
      |                                                    ~~~~~~~~~~~~~~~^~~
#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...