# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1114380 | ttamx | XOR Sum (info1cup17_xorsum) | C++17 | 241 ms | 30160 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int B=1<<30;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
for(auto &x:a){
cin >> x;
}
int ans=0;
for(int b=1;b<B;b<<=1){
vector<int> l,r;
for(auto x:a){
((x&b)?r:l).emplace_back(x);
}
int c=0;
int filter=b*2-1;
auto f=[&](int x){
return x&(filter);
};
for(int t=0;t<2;t++){
for(int i=l.size()-1,p=0;i>=0;i--){
while(p<n&&!((f(l[i])+f(l[p]))&b)){
p++;
}
if(p<=i){
c^=(i-p+1)&1;
}
}
swap(l,r);
}
for(int i=r.size()-1,p=0;i>=0;i--){
while(p<l.size()&&((f(r[i])+f(l[p]))&b)){
p++;
}
c^=p&1;
}
ans|=c*b;
l.insert(l.end(),r.begin(),r.end());
a=move(l);
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |