#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 1000000000000000000
#define MOD 1000000007
#define N 1000005
#define MAX 10000006
#define LOG 30
using namespace std;
int n,ans,a[N];
vector<ii> v;
int main() {
// freopen("input.txt","r",stdin);
scanf("%d",&n);
for(int i=1;i<=n;i++) {
scanf("%d",&a[i]);
v.pb({a[i]&1,i});
}
sort(all(v));
for(int i=0;i<LOG;i++) {
int bas=n,son=n-1;
int ok=0;
for(int j=0;j<n;j++) {
umax(bas,j);
while(son>=0 && v[son].st+v[j].st>pw(i+1)-1) son--;
while(bas-1>=0 && v[bas-1].st+v[j].st>=pw(i)) bas--;
ok^=max(0,(son-bas+1))&1;
}
bas=n,son=n-1;
for(int j=0;j<n;j++) {
umax(bas,j);
while(son>=0 && v[son].st+v[j].st>pw(i+2)-2) son--;
while(bas-1>=0 && v[bas-1].st+v[j].st>=pw(i+1)+pw(i)) bas--;
ok^=max(0,(son-bas+1))&1;
}
if(ok) ans+=pw(i);
vector<ii> v2;
for(int j=0;j<n;j++) if(!(a[v[j].nd]&pw(i+1))) v2.pb(v[j]);
for(int j=0;j<n;j++) if(a[v[j].nd]&pw(i+1)) v2.pb({v[j].st+pw(i+1),v[j].nd});
v=v2;
}
printf("%d",ans);
}
Compilation message
xorsum.cpp: In function 'int main()':
xorsum.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
xorsum.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i]);
~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
259 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1663 ms |
12276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1663 ms |
12276 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
259 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
259 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |