#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=i+1;j<=4000;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+cnt[i];
if(c==1)sum^=(2*i);
}
cout<<sum;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
104 ms |
4316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
104 ms |
4316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Incorrect |
27 ms |
760 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
8 ms |
384 KB |
Output is correct |
3 |
Incorrect |
104 ms |
4316 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |