#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;
int p = sz(v) - 1;
for (int i = 0; i < sz(v); i++) {
while (p - 1 >= 0 && v[i] + v[p - 1] >= t)
p--;
if (v[i] + v[p] >= t)
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
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1526 ms |
9212 KB |
Output is correct |
2 |
Correct |
1389 ms |
12488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1526 ms |
9212 KB |
Output is correct |
2 |
Correct |
1389 ms |
12488 KB |
Output is correct |
3 |
Execution timed out |
1640 ms |
16884 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
3 |
Correct |
194 ms |
3296 KB |
Output is correct |
4 |
Correct |
191 ms |
3548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
348 KB |
Output is correct |
2 |
Correct |
7 ms |
348 KB |
Output is correct |
3 |
Correct |
1526 ms |
9212 KB |
Output is correct |
4 |
Correct |
1389 ms |
12488 KB |
Output is correct |
5 |
Execution timed out |
1640 ms |
16884 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |