#include <bits/stdc++.h>
using namespace std;
vector<long long> haha(0);
long long n;
bool calc(long long k) {
vector<long long> idk(n);
long long br1 = 0,ans = 0,l = 0,r = n-1,p1,p2;
for(long long i = 0; i < n; i++) {
if(haha[i]&(1 << k)) {
br1++;
}
idk[i] = haha[i]%(1 << k);
}
ans+=(br1*(n-br1))%2;
while(l < n) {
if(l > r) {
r++;
}
while(r > l && idk[l]+idk[r-1] >= (1 << k)) {
r--;
}
if(idk[l]+idk[r] >= (1 << k)) {
ans+=((n-r))%2;
ans%=2;
}
l++;
}
p1 = 0;
p2 = n-br1;
for(int i = 0; i < n; i++) {
if(haha[i]&(1 << k)) {
idk[p2] = haha[i];
p2++;
}
else {
idk[p1] = haha[i];
p1++;
}
}
for(int i = 0; i < n; i++) {
haha[i] = idk[i];
idk[i]%=(1 << k);
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long a,ans = 0;
cin >> n;
for(long long i = 0; i < n; i++) {
cin >> a;
haha.push_back(a);
}
for(long long i = 0; i < 30; i++) {
if(calc(i)) {
ans+=(1 << i);
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
468 ms |
16060 KB |
Output is correct |
2 |
Correct |
442 ms |
19244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
468 ms |
16060 KB |
Output is correct |
2 |
Correct |
442 ms |
19244 KB |
Output is correct |
3 |
Correct |
552 ms |
22848 KB |
Output is correct |
4 |
Correct |
536 ms |
22016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
71 ms |
2000 KB |
Output is correct |
4 |
Correct |
70 ms |
2000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
468 ms |
16060 KB |
Output is correct |
4 |
Correct |
442 ms |
19244 KB |
Output is correct |
5 |
Correct |
552 ms |
22848 KB |
Output is correct |
6 |
Correct |
536 ms |
22016 KB |
Output is correct |
7 |
Correct |
71 ms |
2000 KB |
Output is correct |
8 |
Correct |
70 ms |
2000 KB |
Output is correct |
9 |
Correct |
714 ms |
25368 KB |
Output is correct |
10 |
Correct |
692 ms |
25352 KB |
Output is correct |
11 |
Correct |
691 ms |
25436 KB |
Output is correct |