#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) (1<<(x))
#define inf 1000000000000000000
#define MOD 1000000007
#define N 1000006
#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++) {
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-max(j,bas)+1))&1;
}
bas=n,son=n-1;
for(int j=0;j<n;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-max(j,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]);
~~~~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
376 KB |
Output is correct |
2 |
Correct |
9 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1675 ms |
28412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1675 ms |
28412 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
376 KB |
Output is correct |
2 |
Correct |
9 ms |
616 KB |
Output is correct |
3 |
Correct |
257 ms |
28412 KB |
Output is correct |
4 |
Correct |
223 ms |
28412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
376 KB |
Output is correct |
2 |
Correct |
9 ms |
616 KB |
Output is correct |
3 |
Execution timed out |
1675 ms |
28412 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |