이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define watch(x) cout << (#x) << " : " << x << '\n'
using namespace std;
const int LOG = 30;
void solve() {
int n;
cin >> n;
vector <int> a(n);
for (auto& x : a)
cin >> x;
vector <int> cnt(LOG, 0);
for (auto& x : a)
for (int b = 0; b < LOG; b++)
cnt[b] += (x >> b) & 1;
int ans = 0;
for (int b = 0; b < LOG; b++) {
int pairs = 0;
if (cnt[b] * (n - cnt[b]) & 1)
pairs++;
int msk = (1 << b) - 1;
vector <int> c(n);
for (int i = 0; i < n; i++)
c[i] = a[i] & msk;
sort(all(c));
int r = n;
for (int l = 0; l < n; l++) {
while (r - 1 >= l && c[r - 1] + c[l] >= (1 << b))
r--;
pairs += (n - max(l, r));
pairs &= 1;
}
ans ^= (pairs << b);
}
cout << ans << '\n';
}
int32_t main() {
boost;
solve();
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... |