#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+5;
typedef pair<int,int> pii;
vector<pii> b,nol,satu;
int a[MAXN];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,ans=0;
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i];
b.push_back({0,i});
}
for(int bt=0;bt<30;bt++){
nol.clear();
satu.clear();
for(int i=0;i<n;i++){
if((1<<bt) & a[b[i].second]){
satu.push_back({b[i].first+(1<<bt),b[i].second});
}
else{
nol.push_back(b[i]);
}
}
b.clear();
for(auto isi : nol)b.push_back(isi);
for(auto isi : satu)b.push_back(isi);
int notkel2=n-1,notkel3=n-1,notkel4=n-1;
long long cnt=0;
//binser TLE, terpaksa two pointer
for(auto isi : b){
while(notkel2>=0 && isi.first+b[notkel2].first>=(1<<bt))notkel2--;
while(notkel3>=0 && isi.first+b[notkel3].first>=2*(1<<bt))notkel3--;
while(notkel4>=0 && isi.first+b[notkel4].first>=3*(1<<bt))notkel4--;
cnt+=(n-1-notkel4+notkel3-notkel2);
}
for(auto isi : b){
if((2*isi.first) & (1<<bt))cnt++;
}
cnt/=2;
if(cnt&1)ans+=(1<<bt);
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
492 KB |
Output is correct |
2 |
Correct |
5 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
626 ms |
30284 KB |
Output is correct |
2 |
Correct |
558 ms |
29132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
626 ms |
30284 KB |
Output is correct |
2 |
Correct |
558 ms |
29132 KB |
Output is correct |
3 |
Correct |
768 ms |
30304 KB |
Output is correct |
4 |
Correct |
752 ms |
29644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
492 KB |
Output is correct |
2 |
Correct |
5 ms |
492 KB |
Output is correct |
3 |
Correct |
96 ms |
3684 KB |
Output is correct |
4 |
Correct |
96 ms |
3704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
492 KB |
Output is correct |
2 |
Correct |
5 ms |
492 KB |
Output is correct |
3 |
Correct |
626 ms |
30284 KB |
Output is correct |
4 |
Correct |
558 ms |
29132 KB |
Output is correct |
5 |
Correct |
768 ms |
30304 KB |
Output is correct |
6 |
Correct |
752 ms |
29644 KB |
Output is correct |
7 |
Correct |
96 ms |
3684 KB |
Output is correct |
8 |
Correct |
96 ms |
3704 KB |
Output is correct |
9 |
Correct |
1031 ms |
30584 KB |
Output is correct |
10 |
Correct |
1057 ms |
30284 KB |
Output is correct |
11 |
Correct |
1040 ms |
30332 KB |
Output is correct |