# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
636788 | tvladm2009 | XOR Sum (info1cup17_xorsum) | C++14 | 1687 ms | 20500 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |