Pagini recente » Cod sursa (job #3159524) | Cod sursa (job #799060) | Cod sursa (job #3199176) | Cod sursa (job #1895101) | Cod sursa (job #2634943)
#include<bits/stdc++.h>
using namespace std;
#define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
ifstream fin("xormax.in"); ofstream fout("xormax.out");
#define cin fin
#define cout fout
int t, n, m, k, a[100010];
int trie[2100010][2], l=1;
int c[2100000];
void trie_insert(int x){
int crd=1;
for(int i=20; i>=0; i--){
int ac=( ( (1<<i)&x )>0 )?1:0;
if(trie[crd][ac]==0 ){
l++;
trie[crd][ac]=l;
}
crd=trie[crd][ac];
}
}
int trie_find(int x){
int res=0;
int crd=1;
for(int i=20; i>=0; i--){
int ac=( ( x&(1<<i) )>0 )?1:0;
if(trie[crd][ac]==0){
ac=( ac==1 )?0:1;
}
res+=ac*(1<<i);
crd=trie[crd][ac];
}
return res;
}
int32_t main(){
INIT
cin>>n;
a[0]=0;
for(int i=1; i<=n; i++){
cin>>a[i];
a[i]^=a[i-1];
}
trie_insert(0);
int m=0;
int c1=0, c2=0;
for(int i=1; i<=n; i++){
trie_insert(a[i]);
int a2=trie_find(~a[i]);
c[a[i] ]=i;
int c3=c[a2 ];
int c4=i;
int t=c3; c3=min(c3, c4); c4=max(t, c4);
if( (a2^a[i])==m ){
if(c4==c2){
c1=max(c3, c1);
}
if(c4<c2){
c1=c3; c2=c4;
}
}
if( (a2^a[i])>m ){
m=a2^a[i];
c2=c4; c1=c3;
}
t=c1; c1=min(c1, c2); c2=max(t, c2);
}
cout<<m<<" "<<c1+1<<" "<<c2;
return 0;
}