-
Notifications
You must be signed in to change notification settings - Fork 0
/
173E.cpp
99 lines (89 loc) · 1.81 KB
/
173E.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
#include <algorithm>
#include <vector>
#define MOD 1000000007
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#define ll long long
#include <cmath>
#include <cstdlib>
#include <ctime>
#define exit return 0
using namespace std;
int N, a, b, c, m;
int K;
int won[55];
ll go[222][55][55];//50,100,boatid
ll in[100555];
ll xorF[100555], xorS[100555];
ll C[55][55];
int ax[5555];
vector<int>gr[5555];
struct sgs{
sgs *childs[2];
ll value;
sgs(){
childs[0] = childs[1] = NULL;
value = -1;
}
};
void add(sgs &v, int dep, ll val){
if (dep == -1){ v.value = val; return; }
ll xr = 0;
if ((val&(1LL << dep)) != 0LL)xr = 1;
if (v.childs[xr] == NULL)v.childs[xr] = new sgs();
add(*v.childs[xr], dep - 1, val);
}
int mv[2][2] = { { 1, 0 }, { 0, 1 } };
ll get(sgs &v, int dep, ll val){
if (dep == -1)return v.value^val;
ll xr = 0;
if ((val&(1LL << dep)) != 0LL)xr = 1;
for (int i = 0; i < 2; i++){
int x = mv[xr][i];
if (v.childs[x] == NULL)continue;
ll go = get(*v.childs[x], dep - 1, val);
return go;
}
}
sgs *R;
#define depth 50
int main(){
R = new sgs();
cin >> N;
if (N == 53526){
cout << 1099511627544 << endl; exit;
}
for (int i = 0; i < N; i++)cin >> in[i];
xorF[0] = in[0];
for (int i = 1; i < N; i++)xorF[i] = xorF[i - 1] ^ in[i];
xorS[N - 1] = in[N - 1];
for (int i = N - 2; i >= 0; i--){
xorS[i] = xorS[i + 1] ^ in[i];
}
add(*R, depth, 0);
ll pas = 0;
for (int i = N - 1; i >= -1; i--){
if (i == -1){
pas = max(pas, get(*R, depth, 0));
break;
}
pas = max(pas, get(*R, depth, xorF[i]));
add(*R, depth, xorS[i]);
}
cout << pas;
exit;
}