-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathXMAX.cpp
More file actions
55 lines (48 loc) · 1.07 KB
/
XMAX.cpp
File metadata and controls
55 lines (48 loc) · 1.07 KB
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
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#define pb push_back
#define sz(a) int(a.size())
#define reset(a,b) memset(a,b,sizeof(a))
#define oo 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int maxn=100007;
ll a[maxn];
int n;
int main(){
//freopen("input.txt","r",stdin);
scanf("%d",&n);
for(int i=1; i<=n; ++i) scanf("%lld",&a[i]);
int c = 1;
for(int i=60; i>=0 && c<=n; --i){
if(((a[c]>>i) & 1) == 0){
for(int j=c+1; j<=n; ++j)
if((a[j]>>i)&1){
swap(a[c],a[j]);
break;
}
}
if((a[c]>>i)&1){
for(int j=1; j<=n; ++j) if(j!=c && ((a[j]>>i)&1)) a[j]^=a[c];
++c;
}
}
ll res = 0;
for(int i=1; i<=n; ++i) res^=a[i];
cout<<res<<endl;
return 0;
}