# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116606 | 12345678 | XOR Sum (info1cup17_xorsum) | C++17 | 512 ms | 22712 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;
int n, res;
vector<int> v;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
v.resize(n);
for (auto &x:v) cin>>x;
for (int b=1; b<(1<<30); b<<=1)
{
vector<int> l, r;
int cnt=0, idx=0;
for (auto x:v)
{
if (x&b) r.push_back(x);
else l.push_back(x);
}
for (int i=(int)l.size()-1; i>=0; i--)
{
while (idx<l.size()&&!((l[i]+l[idx])&b)) idx++;
if (idx<=i) cnt^=(i-idx+1)%2;
}
for (int i=(int)r.size()-1, idx=0; i>=0; i--)
{
while (idx<r.size()&&!((r[i]+r[idx])&b)) idx++;
if (idx<=i) cnt^=(i-idx+1)%2;
}
for (int i=(int)l.size()-1, idx=0; i>=0; i--)
{
while (idx<r.size()&&(r[idx]+l[i])&b) idx++;
cnt^=idx%2;
}
if (cnt) res|=b;
v=l;
for (auto x:r) v.push_back(x);
}
cout<<res;
}
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... |