Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <cmath>
- #include <climits>
- #include <cstring>
- #include <queue>
- #include <vector>
- #include <set>
- #include <map>
- #include <iostream>
- #include <iterator>
- #include <string>
- #include <algorithm>
- #include <functional>
- #include <utility>
- #define MOD 1000000007
- #define PI 3.1415926535897932384626433832795
- #define INF LONG_MAX
- #define X first
- #define Y second
- #define pb push_back
- #define gc() getchar()
- using namespace std;
- inline void fastRead_int(int &x) {
- register int c = gc();
- x = 0;
- int neg = 0;
- for(; ((c<48 || c>57) && c != '-'); c = gc());
- if(c=='-') {
- neg = 1;
- c = gc();
- }
- for(; c>47 && c<58 ; c = gc()) {
- x = (x<<1) + (x<<3) + c - 48;
- }
- if(neg)
- x = -x;
- }
- struct node
- {
- int value = -1;
- struct node *child[2] = {NULL};
- };
- node *head = NULL;
- void insert_trie(int x)
- {
- int base = 0x00200000;
- node *current = head;
- while(base)
- {
- int digit = base&x;
- digit = (digit == 0)?0:1;
- if(current->child[digit] == NULL)
- current->child[digit] = new node();
- current = current->child[digit];
- base>>=1;
- }
- current->value = x;
- }
- int query_trie(int x)
- {
- node *current = head;
- int base = 0x00200000;
- while(base)
- {
- int digit = base&x;
- digit = (digit == 0)?0:1;
- if(current->child[abs(1-digit)] == NULL)
- current = current->child[digit];
- else
- current = current->child[abs(1-digit)];
- base>>=1;
- }
- return current->value;
- }
- int main(void)
- {
- #ifndef ONLINE_JUDGE
- freopen("in.txt", "r", stdin);
- #endif
- int t,n,tmp;
- fastRead_int(t);
- while(t--)
- {
- fastRead_int(n);
- vector<int> arr(n);
- int maxx = 0;
- int maxIndx;
- head = new node();
- for(int i=0;i<n;i++)
- fastRead_int(arr[i]);
- tmp = 0;
- for(int i=0;i<n;i++)
- {
- tmp = tmp^arr[i];
- if(tmp >= maxx)
- {
- maxx = tmp;
- maxIndx = i;
- }
- }
- int ans = 0,qr;
- tmp = 0;
- insert_trie(0);
- for(int i=0;i<=maxIndx;i++)
- {
- tmp = tmp^arr[i];
- insert_trie(tmp);
- qr = query_trie(maxx);
- ans = ((qr^maxx)>ans)?(qr^maxx):ans;
- }
- printf("%d ", ans);
- arr.clear();
- head = NULL;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement