#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;
int max_val = 0;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
max_val = max(max_val, a[i]);
}
int ans = 0;
int up_to = 0;
int curr = 1;
while (curr < max_val)
{
++up_to;
curr *= 2;
}
for (int i = 0; i <= up_to; ++i)
{
if (check(i) == true)
{
ans += (1 << i);
}
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
8 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
607 ms |
12264 KB |
Output is correct |
2 |
Correct |
573 ms |
11784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
607 ms |
12264 KB |
Output is correct |
2 |
Correct |
573 ms |
11784 KB |
Output is correct |
3 |
Correct |
1325 ms |
12236 KB |
Output is correct |
4 |
Correct |
1176 ms |
12188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
8 ms |
340 KB |
Output is correct |
3 |
Correct |
187 ms |
1656 KB |
Output is correct |
4 |
Correct |
185 ms |
1652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
340 KB |
Output is correct |
2 |
Correct |
8 ms |
340 KB |
Output is correct |
3 |
Correct |
607 ms |
12264 KB |
Output is correct |
4 |
Correct |
573 ms |
11784 KB |
Output is correct |
5 |
Correct |
1325 ms |
12236 KB |
Output is correct |
6 |
Correct |
1176 ms |
12188 KB |
Output is correct |
7 |
Correct |
187 ms |
1656 KB |
Output is correct |
8 |
Correct |
185 ms |
1652 KB |
Output is correct |
9 |
Execution timed out |
1654 ms |
21624 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |