이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int M = 29;
unordered_map<int, int> f;
void add(int pos, int sz) {
for (; pos < sz; pos |= pos + 1) {
f[pos]++;
}
}
int get(int pos) {
int res = 0;
for (; pos >= 0; pos = (pos & (pos + 1)) - 1) {
res += f[pos];
}
return res;
}
int get(int l, int r) {
if (l > r) {
return 0;
}
return get(r) - get(l - 1);
}
const int N = 1e6;
int a[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ans = 0;
int pw = 2;
for (int b = 0; b < M; b++) {
f.clear();
int kek = 0;
for (int i = 0; i < n; i++) {
int t = a[i] % pw;
add(t, pw);
if (a[i] & (1 << b)) {
kek += get(0, pw - 1 - t)
+ get(pw - t + pw / 2, pw - 1);
kek &= 1;
} else {
kek += get(pw / 2 - t, pw - 1 - t);
kek &= 1;
}
}
ans += kek * pw / 2;
pw <<= 1;
}
cout << ans;
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... |