#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
ll v[MAXN];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
cin>>n;
if(n <= 4e3){
ll ans = 0;
for(int i = 0; i < n; i++){
cin>>v[i];
for(int j = 0; j <= i; j++){
ans ^= (v[i]+v[j]);
}
}
cout<<ans<<endl;
}else{
ll ans = 0;
for(int i = 0; i < n; i++){
int a;
cin>>a;
v[a]++;
}
for(int i = 1; i <= 4e3; i++){
for(int j = 1; j < i; j++){
ll cnt = 1LL*v[i]*v[j];
if(cnt % 2){
//cout<<i<<endl;
ans ^= (i + j);
}
}
if((1LL*v[i]*(v[i] + 1) / 2) % 2){
ans ^= (2*i);
}
}
cout<<ans<<endl;
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
108 ms |
384 KB |
Output is correct |
2 |
Correct |
106 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
108 ms |
384 KB |
Output is correct |
2 |
Correct |
106 ms |
504 KB |
Output is correct |
3 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
108 ms |
384 KB |
Output is correct |
4 |
Correct |
106 ms |
504 KB |
Output is correct |
5 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |