#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define ep emplace
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define mem(f,x) memset(f , x , sizeof(f))
#define sz(x) (ll)(x).size()
#define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b))
#define mxx *max_element
#define mnn *min_element
#define cntbit(x) __builtin_popcountll(x)
#define len(x) (int)(x.length())
const int N = 1e6 + 10;
int a[N], n;
vector <int> v;
ll cal(int t) {
ll ans = 0;
for (int i = 0; i < sz(v); i++) {
int p = lower_bound(all(v), t - v[i]) - v.begin();
ans += max(0, i - p + 1);
}
return ans;
}
int is(int j) {
ll t = cal((1 << (j + 1)) | ((1 << j))) + cal((1 << (j + 1))) - cal(1 << j);
return t % 2;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int ans = 0;
for (int j = 0; j < 30; j++) {
v.clear();
for (int i = 1; i <= n; i++) {
v.pb(a[i] % (1 << ((j + 1))));
}
sort(all(v));
if (is(j))
ans |= (1 << j);
}
cout << ans << '\n';
return 0;
}
/*
011
011
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
348 KB |
Output is correct |
2 |
Correct |
12 ms |
560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1622 ms |
9672 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1622 ms |
9672 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
348 KB |
Output is correct |
2 |
Correct |
12 ms |
560 KB |
Output is correct |
3 |
Correct |
328 ms |
4064 KB |
Output is correct |
4 |
Correct |
316 ms |
4064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
348 KB |
Output is correct |
2 |
Correct |
12 ms |
560 KB |
Output is correct |
3 |
Execution timed out |
1622 ms |
9672 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |