#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
int n;
int a[maxn];
bool check(int bit)
{
int result = 0;
int cnt = 0;
vector<int> rems;
for (int i = 1; i <= n; ++i)
{
if ((a[i] & (1 << bit)) != 0)
{
++cnt;
}
rems.push_back((a[i] % (1 << bit)));
}
result = (1LL * result + (1LL * cnt) * (1LL * (n - cnt))) % 2;
sort(rems.begin(), rems.end());
int r = n - 1;
for (int l = 0; l < n; ++l)
{
if (l > r)
{
++r;
}
while (r > l && rems[l] + rems[r - 1] >= (1 << bit))
{
--r;
}
if (rems[l] + rems[r] >= (1 << bit))
{
result = (result + n - r) % 2;
}
}
return result;
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
int ans = 0;
for (int i = 0; i <= 29; ++i)
{
if (check(i) == true)
{
ans += (1 << i);
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1614 ms |
12256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1614 ms |
12256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
420 KB |
Output is correct |
3 |
Correct |
188 ms |
2572 KB |
Output is correct |
4 |
Correct |
185 ms |
2552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
420 KB |
Output is correct |
3 |
Execution timed out |
1614 ms |
12256 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |