이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
// 0 <= x, y <= 2^(k+1)
// (x+y) & (2^k) > 0
// 2^k <= x+y < 2^(k+1)
// 2^(k+1) <= x+y < 2^(k+2)
int main()
{
ios :: sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<int> v(n);
for (int &x : v)
cin >> x;
int res = 0;
for (int k = 0; k < 30; ++k)
{
// radix sort
{
vector<int> a, b;
for (int &x : v)
{
if (x >> k & 1) b.pb(x);
else a.pb(x);
}
v.clear();
for (int x : a)
v.pb(x);
for (int x : b)
v.pb(x);
}
ll C = 0;
int R = (1 << (k+1)) - 1;
int l = n-1, r = n-1;
for (int i = 0; i < n; ++i)
{
while (l >= 0 && (v[i] & R) + (v[l] & R) >= (1 << k)) l--;
while (r >= 0 && (v[i] & R) + (v[r] & R) >= (1 << (k+1))) r--;
C += max(0, r - max(l, i-1));
}
l = r = n-1;
for (int i = 0; i < n; ++i)
{
while (l >= 0 && (v[i] & R) + (v[l] & R) >= (1 << (k+1)) + (1 << k)) l--;
while (r >= 0 && (v[i] & R) + (v[r] & R) >= (1 << (k+1)) + (1 << (k+1))) r--;
C += max(0, r - max(l, i-1));
}
if (C & 1) res ^= (1 << k);
}
cout << res << '\n';
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... |