#include<bits/stdc++.h> usingnamespace std; constint N = 100000; constint M = N * 32 + 1; int trie[M][2], idx; voidadd( int x ){ int p = 0; for ( int i = 31; i >= 0; --i) { int u = x >> i & 1; int &t = trie[p][u]; if ( !t ) t = ++idx; p = t; } } intquery( int x ){ int ret = 0, p = 0; int u = x >> 31 & 1; if ( !trie[p][u] ) { ret |= 1 << 31; u ^= 1; } p = trie[p][u]; for ( int i = 30; i >= 0; --i ) { u = x >> i & 1; int &t = trie[p][u ^ 1]; if ( t ) { ret |= 1 << i; p = t; } else p = trie[p][u]; } return ret; } intmain() { int n, x; int ret = 0, eor = 0; scanf("%d", &n); while ( n-- ) { scanf("%d", &x); eor ^= x; ret = max( ret, query(eor) ); add( eor ); } printf("%d\n", ret); return0; }
#include<bits/stdc++.h> usingnamespace std; constint N =( 1e5 + 10) * 31, M = 1e5 + 10; int son[N][2],idx,arr[M], s[M],cnt[N]; voidinsert(int x, int val){ int p = 0; for(int i = 30 ;i >= 0; i --){ int u = x >> i & 1; if(!son[p][u])son[p][u] = ++idx; p = son[p][u]; cnt[p] += val; } } intquery(int x){ int p = 0,res = 0; for(int i = 30; i >= 0; i --){ int u = x >> i & 1; if(cnt[ son[p][!u] ] ){ res += 1 << i; p = son[p][!u]; } else p = son[p][u]; } return res; } intmain() { int n,m,res = 0; cin>>n>>m; for(int i = 1; i <= n; i ++ ){ int x; cin>>x; s[i] = s[i - 1] ^ x; } insert(s[0],1); for(int i = 1;i <= n; i ++ ){ if(i > m )insert(s[i - m - 1], -1); res = max(res, query(s[i])); insert(s[i],1); } cout<<res; }