Skip to content

Instantly share code, notes, and snippets.

@koosaga
Created October 9, 2016 13:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koosaga/5063c7b2307d61287ce35a0777147115 to your computer and use it in GitHub Desktop.
Save koosaga/5063c7b2307d61287ce35a0777147115 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
int n;
lint basis[60];
int main(){
cin >> n;
for(int i=0; i<n; i++){
lint x;
scanf("%lld",&x);
for(int j=59; j>=0; j--){
if((x >> j) & 1){
if(!basis[j]){
basis[j] = x;
break;
}
else x ^= basis[j];
}
}
}
lint dap = 0;
for(int i=59; i>=0; i--){
dap = max(dap, dap ^ basis[i]);
}
cout << dap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment