#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
return (ull)rng() % B;
}
struct fastI{
char in[1<<25];
char const*o;
fastI(){
o = in;
in[fread(in,1,sizeof(in)-4,stdin)]=0;
}
fastI& operator>>(char& c){
while(*o&&*o<=32)++o;
c=*o++;
return *this;
}
fastI& operator>>(int& u){
u=0;
unsigned s=0;
while(*o&&*o<=32)++o;
if (*o == '-')s = ~s, ++o; else if (*o == '+')++o;
while('0'<=*o && *o<='9')u = (u<<3) + (u << 1) + (*o++ - '0');
(u^=s)+=!!s;
return *this;
}
fastI& operator>>(long long& u){
u=0;
uint64_t s=0;
while(*o&&*o<=32)++o;
if (*o == '-')s = ~s, ++o; else if (*o == '+')++o;
while('0'<=*o && *o<='9')u = (u<<3) + (u << 1) + (*o++ - '0');
(u^=s)+=!!s;
return *this;
}
} fin;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n; fin >> n;
vector<int> a(n);
for(int i=0;i<n;i++){
fin >> a[i];
}
int res=0;
for(int v=(1<<28);v;v>>=1){
for(int i=0;i<n;i++){
a[i]&=(v*2-1);
}
sort(a.begin(), a.end());
int t=0;
for(int i=n-1,j=0,k=0,l=0;i>=0;i--){
j=min(j,i); k=min(k,i); l=min(l,i);
while(j<i+1 and a[i]+a[j]<v)j++;
while(k<i+1 and a[i]+a[k]<2*v)k++;
while(l<i+1 and a[i]+a[l]<3*v)l++;
t+=(k-j)+(n-l);
t&=1;
}
if(t)res^=v;
}
cout << res << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
332 KB |
Output is correct |
2 |
Correct |
6 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
783 ms |
8852 KB |
Output is correct |
2 |
Correct |
747 ms |
8268 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
783 ms |
8852 KB |
Output is correct |
2 |
Correct |
747 ms |
8268 KB |
Output is correct |
3 |
Correct |
1166 ms |
10980 KB |
Output is correct |
4 |
Correct |
1125 ms |
10592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
332 KB |
Output is correct |
2 |
Correct |
6 ms |
332 KB |
Output is correct |
3 |
Correct |
164 ms |
1644 KB |
Output is correct |
4 |
Correct |
163 ms |
1648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
332 KB |
Output is correct |
2 |
Correct |
6 ms |
332 KB |
Output is correct |
3 |
Correct |
783 ms |
8852 KB |
Output is correct |
4 |
Correct |
747 ms |
8268 KB |
Output is correct |
5 |
Correct |
1166 ms |
10980 KB |
Output is correct |
6 |
Correct |
1125 ms |
10592 KB |
Output is correct |
7 |
Correct |
164 ms |
1644 KB |
Output is correct |
8 |
Correct |
163 ms |
1648 KB |
Output is correct |
9 |
Execution timed out |
1694 ms |
13516 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |