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 maxn = 1000005;
int n;
int a[maxn];
bool check(int bit)
{
int result = 0;
int cnt = 0;
vector<int> rems;
for (int i = 1; i <= n; ++i)
{
if ((a[i] & (1 << bit)) != 0)
{
++cnt;
}
rems.push_back((a[i] % (1 << bit)));
}
result = (1LL * result + (1LL * cnt) * (1LL * (n - cnt))) % 2;
sort(rems.begin(), rems.end());
int r = n - 1;
for (int l = 0; l < n; ++l)
{
if (l > r)
{
++r;
}
while (r > l && rems[l] + rems[r - 1] >= (1 << bit))
{
--r;
}
if (rems[l] + rems[r] >= (1 << bit))
{
result = (result + n - r) % 2;
}
}
return result;
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n;
int max_val = 0;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
max_val = max(max_val, a[i]);
}
int ans = 0;
int up_to = 0;
int curr = 1;
while (curr < max_val)
{
++up_to;
curr *= 2;
}
for (int i = 0; i <= up_to; ++i)
{
if (check(i) == true)
{
ans += (1 << i);
}
}
cout << ans << endl;
return 0;
}
# | 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... |