Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.3 kB
1
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define EPS 1e-9
// #define mod 1000000007
#define mod 998244353
#define over 10000000000
#define sz(m) (ll)(m.size())
#define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
bool sortbysecdesc(pair<int, int> &a, pair<int, int> &b)
{
  if (a.first == b.first)
    return a.second > b.second;
  else
    return a.first < b.first;
}
#define fixed(n) fixed << setprecision(n)
const ll inf = 1e18 + 5;
// vector< vector <int> > nums( n , vector<int> (m)) ;
//  priority_queue<int, vector<int>, greater<int> > pq ;
template <typename T = int>
istream &operator>>(istream &in, vector<T> &v)
{
  for (T &i : v)
    in >> i;
  return in;
}
template <typename T = int>
ostream &operator<<(ostream &out, const vector<T> &v)
{
  for (const T &x : v)
    out << x << ' ';
  return out;
}

void lol()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin), freopen("outputt.txt", "w", stdout), freopen("error.txt", "w", stderr);
#endif
}
double log(double base, double x)
{
  return (log(x) / log(base));
}

// count(begin(nums), end(nums), 0);
bool comp(const pair<int, int> &a, const pair<int, int> &b)
{
  if (a.first > b.first)
    return (a.second > b.second);
  else
    return (a.second < b.second);
}
ll ncr(ll n, ll r)
{
  vector<ll> inv(r + 1);
  ll ans = 1;
  inv[0] = 1;
  if (r + 1 >= 2)
    inv[1] = 1;
  for (int i = 2; i <= r; i++)
    inv[i] = mod - (mod / i) * inv[mod % i] % mod;
  // to get 1 / (r!)
  for (int i = 2; i <= r; i++)
    ans = ((ans % mod) * (inv[i] % mod)) % mod;
  for (int i = n; i >= (n - r + 1); i--)
    ans = ((ans % mod) * (i % mod)) % mod;
  return ans;
}
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
ll fast_power(ll base, ll p)
{
  if (!p)
    return 1;
  unsigned ll ret = fast_power(base, p / 2);
  ret = (ret * ret) % mod;
  if (p % 2)
    ret = (ret * base) % mod;
  return ret % mod;
}
int add(ll a, ll b)
{

  return (a + b) % mod;
}
/////////////////////////////////////////////////////////
struct trie
{

  trie *child[2];
  trie()
  {
    memset(child, 0, sizeof child);
  }
};
trie *root;
void insert(ll num)
{
  trie *p = root;
  for (ll i = 40; i >= 0; i--)
  {
    bool cur = (1LL << i) & num;
    if (!p->child[cur])
      p->child[cur] = new trie();
    p = p->child[cur];
  }
}
ll mx_xor(ll val)
{
  ll ans = 0;
  trie *p = root;
  for (int i = 40; i >= 0; i--)
  {
    int cur = val & (1LL << i);
    if (p->child[!cur])
    {
      ans += (1LL << i);
      p = p->child[!cur];
    }
    if (p->child[cur])
    {
      p = p->child[cur];
    }
  }
  return ans;
}

int main()
{
  lol();
  int t = 1;
  // cin >> t;
  while (t--)
  {
    int n;
    cin >> n;
    vector<ll> in(n);
    cin >> in;
    trie *root = new trie();
    ll suff = 0, pre = 0, ans = 0;
    for (int i = 0; i < n; i++)
    {
      suff ^= in[i];
    }
    for (int i = 0; i <=n; i++)
    {
      insert(pre);
      ans = max(ans, mx_xor(suff));
      if (i < n)
      {
        pre ^= in[i];
        suff ^= in[i];
      }
    }
    cout << ans;
  }
}