//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int M = 29;
unordered_map<int, int> f;
void add(int pos, int sz) {
for (; pos < sz; pos |= pos + 1) {
f[pos]++;
}
}
int get(int pos) {
int res = 0;
for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
res += f[pos];
}
return res;
}
int get(int l, int r) {
if (l > r) {
return 0;
}
return get(r) - get(l - 1);
}
const int N = 1e6;
int a[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ans = 0;
int pw = 2;
for (int b = 0; b < M; b++) {
f.clear();
int kek = 0;
for (int i = 0; i < n; i++) {
int t = a[i] % pw;
add(t, pw);
if (a[i] & (1 << b)) {
kek += get(0, pw - 1 - t)
+ get(pw - t + pw / 2, pw - 1);
kek &= 1;
} else {
kek += get(pw / 2 - t, pw - 1 - t);
kek &= 1;
}
}
ans += kek * pw / 2;
pw <<= 1;
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
210 ms |
4500 KB |
Output is correct |
2 |
Correct |
231 ms |
4440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1677 ms |
8912 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1677 ms |
8912 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
210 ms |
4500 KB |
Output is correct |
2 |
Correct |
231 ms |
4440 KB |
Output is correct |
3 |
Execution timed out |
1616 ms |
26116 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
210 ms |
4500 KB |
Output is correct |
2 |
Correct |
231 ms |
4440 KB |
Output is correct |
3 |
Execution timed out |
1677 ms |
8912 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |