#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int NMAX = 1e6+2;
int n,v[NMAX];
void bitrep(int n){
for(int i = 0; i < 8; i++){
int bt = (n>>i)&1;
cout << bt;
}
cout << " = " << n << "\n";
}
int brut(int k){
int ans = 0;
int mod = (1<<(k+1));
int l = (1<<k), r = (1<<(k+1))-1;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= i; j++){
int sum = (v[i]+v[j])%mod;
int bt = (sum>>k)&1;
if(bt){
assert(l <= sum && sum <= r);
}
ans += bt;
}
}
return ans;
}
bool inauntru(int x, pii interv){
auto [l, r] = interv;
return (l <= x && x <= r);
}
int cnt(int k){
int mod = (1<<(k+1));
int ans = 0;
for(int i = 1; i <= n; i++){
int val = v[i]%mod;
int l = (1<<k), r = (1<<(k+1))-1;
l = (l-val+mod)%mod;
r = (r-val+mod)%mod;
pii ranges[2];
if(l <= r){
ranges[0] = ranges[1] = {l, r};
}else{
ranges[0] = {0, r};
ranges[1] = {l, (1<<(k+1))-1};
}
for(int j = 1; j <= i; j++){
if(inauntru(v[j]%mod, ranges[0]) || inauntru(v[j]%mod, ranges[1])){
ans++;
}
}
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> v[i];
}
int ans = 0;
for(int i = 0; i < 30; i++){
ans += (cnt(i)&1)*(1<<i);
}
cout << ans;
return 0;
}
Compilation message
xorsum.cpp: In function 'bool inauntru(int, pii)':
xorsum.cpp:33:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
33 | auto [l, r] = interv;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1647 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1642 ms |
4184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1642 ms |
4184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1647 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1647 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |