#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
int n, lg, ii;
vector<int> a, L, R;
void init_(int _n) {
n = _n, lg = 32;
a.assign(n + 1, 0);
}
int solve() {
int ans = 0;
rep(i, 0, lg) {
L.clear(), R.clear(), ii = 0;
rep(j, 1, n) {
if((a[j] >> i) & 1) R.push_back(a[j]);
else L.push_back(a[j]);
}
for(auto j : L) a[++ii] = j;
for(auto j : R) a[++ii] = j;
int p1 = n, p2 = n, p3 = n, mask = ((int)1 << (i + 1)) - 1;
int x = ((int)1 << i), y = ((int)1 << i) * 2, z = ((int)1 << i) * 3;
rep(j, 1, n) {
int cur = a[j] & mask;
while(p1 && cur + (a[p1] & mask) >= x) p1 --;
while(p2 && cur + (a[p2] & mask) >= y) p2 --;
while(p3 && cur + (a[p3] & mask) >= z) p3 --;
if((n - max(p3, j - 1) + max(p2, j - 1)
- max(p1, j - 1)) & 1) ans ^= (1 << i);
}
}
return ans;
}
};
using namespace solver;
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int n; cin >> n; init_(n);
rep(i, 1, n) cin >> a[i];
cout << solve() << "\n";
return 0;
}
Compilation message
xorsum.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
4 | #pragma loop-opt(on)
|
xorsum.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
xorsum.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
528 ms |
26232 KB |
Output is correct |
2 |
Correct |
515 ms |
27368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
528 ms |
26232 KB |
Output is correct |
2 |
Correct |
515 ms |
27368 KB |
Output is correct |
3 |
Correct |
663 ms |
32972 KB |
Output is correct |
4 |
Correct |
622 ms |
32300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Correct |
96 ms |
3140 KB |
Output is correct |
4 |
Correct |
108 ms |
4112 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Correct |
528 ms |
26232 KB |
Output is correct |
4 |
Correct |
515 ms |
27368 KB |
Output is correct |
5 |
Correct |
663 ms |
32972 KB |
Output is correct |
6 |
Correct |
622 ms |
32300 KB |
Output is correct |
7 |
Correct |
96 ms |
3140 KB |
Output is correct |
8 |
Correct |
108 ms |
4112 KB |
Output is correct |
9 |
Correct |
888 ms |
35624 KB |
Output is correct |
10 |
Correct |
889 ms |
35752 KB |
Output is correct |
11 |
Correct |
875 ms |
35640 KB |
Output is correct |