//#include "/Users/stdc++.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("tune=native")
#pragma GCC optimize("unroll-loops")
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;
int n, a[maxn], inds[maxn], bit;
vector < int > for_sort[2];
bool get_bit(int x, int k) {
return x & (1 << k);
}
void Sort() {
for (int i = 0; i < n; i++) {
int ind = inds[i];
for_sort[get_bit(a[ind], bit)].pb(ind);
}
int ind = 0;
for (int i = 0; i < 2; i++) {
for (int j = 0; j < sz(for_sort[i]); j++)
inds[ind++] = for_sort[i][j];
for_sort[i].clear();
}
}
int get_val(int i, int j) {
int x = a[inds[i]] % (1 << (bit + 1));
int y = a[inds[j]] % (1 << (bit + 1));
return x + y;
}
void upd_p(int &p, int i, int add) {
if (p < i) p = i;
while (i < p && get_val(i, p - 1) >= add * (1 << bit))
p--;
}
int main() {
fast_io
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
inds[i] = i;
}
int ans = 0;
for (bit = 0; bit < 14; bit++) {
Sort();
int p1 = n, p2 = n, p3 = n;
for (int i = 0; i < n; i++) {
upd_p(p1, i, 1);
upd_p(p2, i, 2);
upd_p(p3, i, 3);
int cnt_ones = p2 - p1 + n - p3;
if (cnt_ones % 2) ans ^= (1 << bit);
}
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
818 ms |
17248 KB |
Output is correct |
2 |
Correct |
727 ms |
21088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
818 ms |
17248 KB |
Output is correct |
2 |
Correct |
727 ms |
21088 KB |
Output is correct |
3 |
Incorrect |
906 ms |
24160 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |