#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e6+5;
int n,a[N],mx;
int cnt[N];
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
mx=max(mx,a[i]);
}
if(n<=4000){
int sum=0;
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
sum^=(a[i]+a[j]);
}
}
cout<<sum;
}else if(mx<=4000){
int sum=0;
for(int i=1;i<=n;i++)cnt[a[i]]++;
for(int i=1;i<=4000;i++){
for(int j=1;j<=4000;j++){
if(i!=j){
int c=cnt[i]*cnt[j];
if(c%2==1)sum^=(i+j);
}
}
}
for(int i=1;i<=4000;i++){
int c=cnt[i]*(cnt[i-1])/2;
if(c==1)sum^=(2*i);
}
for(int i=1;i<=4000;i++){
if(cnt[i]%2==1)sum^=(2*i);
}
cout<<sum;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
185 ms |
8824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
185 ms |
8824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Incorrect |
15 ms |
1664 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Incorrect |
185 ms |
8824 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |