Submission #636788

#TimeUsernameProblemLanguageResultExecution timeMemory
636788tvladm2009XOR Sum (info1cup17_xorsum)C++14
0 / 100
1687 ms20500 KiB
#include <iostream> #include <algorithm> #define int long long using namespace std; const int MAX_N = 1e6; int a[MAX_N + 1], v[MAX_N + 1]; int n, answer = 0; int cb(int value) { int l = 1, r = n, sol = n + 1; while (l < r) { int mid = (l + r) / 2; if (v[mid] < value) { sol = mid; l = mid + 1; } else { r = mid - 1; } } return sol; } void solve(int bit) { for (int i = 1; i <= n; i++) { v[i] = a[i] % (1LL << (bit + 1)); } sort(v + 1, v + n + 1); for (int i = 1; i <= n; i++) { int p1 = cb(1LL << bit); int p2 = cb(1LL << (bit + 1)); int p3 = cb(1LL << (bit + 2)); int p4 = cb(1LL << (bit + 3)); if ((p2 - p1 + n + 1 - p3) & 1) { answer += (1LL << bit); } } } signed main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int b = 0; b < 30; b++) { solve(b); } cout << answer; return 0; }

Compilation message (stderr)

xorsum.cpp: In function 'void solve(long long int)':
xorsum.cpp:34:13: warning: unused variable 'p4' [-Wunused-variable]
   34 |         int p4 = cb(1LL << (bit + 3));
      |             ^~
#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...