#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1e6+6;
const int logN=30;
int n;
int a[MAXN],a1[MAXN];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>a[i];
}
int ans=0;
for(int j=0;j<logN;++j)
{
int sz=0;
if(j!=0)
{
for(int i=1;i<=n;++i)
{
if(!(a[i]&(1<<(j-1))))
{
a1[++sz]=a[i];
}
}
for(int i=1;i<=n;++i)
{
if(a[i]&(1<<(j-1)))
{
a1[++sz]=a[i];
}
}
for(int i=1;i<=n;++i)a[i]=a1[i];
}
ll cnt0up=0,cnt1up=0,cnt0down=0,cnt1down=0;
int p=n;
ll cnt=0;
for(int i=1;i<=n;++i)
{
if(a[i]&(1<<j))++cnt1up;
else ++cnt0up;
}
for(int i=1;i<=n;++i)
{
while(p>0&&a[p]%(1<<j)+a[i]%(1<<j)>=(1<<j))
{
if(a[p]&(1<<j))++cnt1down,--cnt1up;
else ++cnt0down,--cnt0up;
--p;
}
if(a[i]&(1<<j))
{
cnt+=cnt0up+cnt1down;
}
else
{
cnt+=cnt1up+cnt0down;
}
if((2*a[i])&(1<<j))++cnt;
}
//cout<<j<<" "<<cnt<<endl;
if((cnt/2)%2==1)
{
ans+=(1<<j);
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
396 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
756 ms |
8300 KB |
Output is correct |
2 |
Correct |
706 ms |
7764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
756 ms |
8300 KB |
Output is correct |
2 |
Correct |
706 ms |
7764 KB |
Output is correct |
3 |
Correct |
1036 ms |
8172 KB |
Output is correct |
4 |
Correct |
977 ms |
8044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
396 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
147 ms |
1132 KB |
Output is correct |
4 |
Correct |
145 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
396 KB |
Output is correct |
2 |
Correct |
7 ms |
364 KB |
Output is correct |
3 |
Correct |
756 ms |
8300 KB |
Output is correct |
4 |
Correct |
706 ms |
7764 KB |
Output is correct |
5 |
Correct |
1036 ms |
8172 KB |
Output is correct |
6 |
Correct |
977 ms |
8044 KB |
Output is correct |
7 |
Correct |
147 ms |
1132 KB |
Output is correct |
8 |
Correct |
145 ms |
1260 KB |
Output is correct |
9 |
Correct |
1442 ms |
8284 KB |
Output is correct |
10 |
Correct |
1412 ms |
8300 KB |
Output is correct |
11 |
Correct |
1429 ms |
17572 KB |
Output is correct |