#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 <= 19; ++i)
{
if (check(i) == true)
{
ans += (1 << i);
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1014 ms |
16944 KB |
Output is correct |
2 |
Correct |
981 ms |
16024 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1014 ms |
16944 KB |
Output is correct |
2 |
Correct |
981 ms |
16024 KB |
Output is correct |
3 |
Correct |
1140 ms |
19076 KB |
Output is correct |
4 |
Incorrect |
1101 ms |
18556 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |