#include <bits/stdc++.h>
using namespace std;
vector<long long> haha(0);
long long n;
bool calc(long long k) {
vector<long long> idk(0);
long long br1 = 0,ans = 0,l = 0,r = n-1;
for(long long i = 0; i < n; i++) {
idk.push_back(haha[i]%(1 << k));
if(haha[i]&(1 << k)) {
br1++;
}
}
ans+=(br1*(n-br1))%2;
sort(idk.begin(),idk.end());
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++;
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1658 ms |
29012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1658 ms |
29012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Correct |
196 ms |
3876 KB |
Output is correct |
4 |
Correct |
194 ms |
3848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
1658 ms |
29012 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |