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 "/Users/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair < int, int >
#define fs first
#define sc second
#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;
typedef long double ld;
const int INF = 2e9;
const ll BIG_INF = 1e18;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
pii x[maxn], for_sort[2][maxn];
int n, a[maxn], sz[2], bit;
bool get_bit(int x, int k) {
return x & (1 << k);
}
void Sort() {
for (int i = 0; i < n; i++)
if (get_bit(a[x[i].sc], bit))
x[i].fs |= 1 << bit;
sz[0] = sz[1] = 0;
for (int i = 0; i < n; i++) {
int ind = get_bit(x[i].fs, bit);
for_sort[ind][sz[ind]++] = x[i];
}
int ind = 0;
for (int i = 0; i < 2; i++)
for (int j = 0; j < sz[i]; j++)
x[ind++] = for_sort[i][j];
}
int main() {
fast_io
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
x[i].sc = i;
}
int ans = 0;
for (bit = 0; bit < 30; bit++) {
Sort();
int val = 1 << bit, p1 = n, p2 = n, p3 = n;
for (int i = 0; i < n; i++) {
if (p1 < i) p1 = i;
while (i < p1 && x[i].fs + x[p1 - 1].fs >= val)
p1--;
if (p2 < i) p2 = i;
while (i < p2 && x[i].fs + x[p2 - 1].fs >= 2 * val)
p2--;
if (p3 < i) p3 = i;
while (i < p3 && x[i].fs + x[p3 - 1].fs >= 3 * val)
p3--;
if ((p2 - p1 + n - p3) % 2)
ans ^= (1 << bit);
}
}
cout << ans << "\n";
return 0;
}
# | 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... |