#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int L = 50;
map<ll, ll> mp[L];
ll calc(int left, int right, int mod) {
if (left > right) return 0;
ll cnt = 0;
for(auto i : mp[mod]) {
if (i.first >= left && i.first <= right) {
cnt += i.second;
// cout << i.first << " " << i.second << "\n";
}
}
return cnt;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<ll> a(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
vector<ll> cnt(L, 0);
vector<ll> p(L);
p[0] = 1LL;
for(int i = 1; i < L; i++) {
p[i] = p[i-1] * 2LL;
// cout << p[i] << "\n";
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < L; j++) {
mp[j][a[i]%p[j]]++;
}
}
for(int i = 0; i < L; i++) {
mp[i][-1] = 0;
}
for(int i = 0; i < n; i++) {
int x = a[i];
for(int j = 0; j < L-3; j++) {
if ((x+x) & p[j]) {
cnt[j]++;
}
// cout << x << "\n";
if (x & p[j]) {
int left = 0;
int right = p[j] - (x % p[j]) - 1;
// cout << "[" << left << "," << right << "]" << "\n";
cnt[j] += calc(left, right, j+1);
// cnt[j] %= 2;
left = p[j+1] - (x % p[j]);
right = p[j+1] - 1;
cnt[j] += calc(left, right, j+1);
// cnt[j] %= 2;
// cout << "[" << left << "," << right << "]" << "\n\n";
} else {
int left = p[j] - (x % p[j]);
int right = (p[j+1]-1) - (x % p[j]);
cnt[j] += calc(left, right, j+1);
// cout << "[" << left << "," << right << "]\n\n";
// cnt[j] %= 2;
}
// cout << cnt[j] << "\n";
}
}
// for(int i = 0; i < L; i++) {
// ll add = 0;
// for(auto& j : mp[i]) {
// j.second += add;
// add = j.second;
// }
// }
ll ans = 0;
for(int i = 0; i < L; i++) {
cnt[i] /= 2;
// cout << cnt[i] << " ";
if (cnt[i] % 2) {
ans += p[i];
}
}
// cerr << "\n";
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1679 ms |
9796 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1692 ms |
17868 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1692 ms |
17868 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1679 ms |
9796 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1679 ms |
9796 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |