#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
typedef long long llong;
const int MAXN = 1000000 + 10;
const int MAXLOG = 30;
int n;
int cnt[2];
int a[MAXN];
int b[MAXN];
int c[MAXN];
int perm[MAXN];
int perm2[MAXN];
int answer;
void solve()
{
for (int bit = 0 ; bit < MAXLOG ; ++bit)
{
int cntOnes = 0;
std::iota(c + 1, c + 1 + n, 1);
std::sort(c + 1, c + 1 + n, [&](int x, int y)
{
return b[x] < b[y];
});
int ptr = n + 1;
llong count = 1LL * cntOnes * (n - cntOnes);
for (int i = 1 ; i <= n ; ++i)
{
while (ptr > 1 && b[c[ptr - 1]] + b[c[i]] >= (1 << bit))
{
ptr--;
}
count += n + 1 - ptr;
}
if (count & 1)
{
answer |= (1 << bit);
}
for (int i = 1 ; i <= n ; ++i)
{
b[i] |= (a[i] & (1 << bit));
cntOnes += ((a[i] & (1 << bit)) > 0);
}
}
std::cout << answer << '\n';
}
void input()
{
std::cin >> n;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> a[i];
}
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1661 ms |
18028 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1661 ms |
18028 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |