mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 11:58:48 +00:00
3164. 线性基
https://www.acwing.com/problem/content/submission/code_detail/14619728/
This commit is contained in:
parent
6cc4f14081
commit
74f0ad0207
45
AcWing/3164/3164.cpp
Normal file
45
AcWing/3164/3164.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include <iostream>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
|
||||
int n;
|
||||
unsigned long long x, a[N], ans;
|
||||
|
||||
inline void insert(unsigned long long x) {
|
||||
for (int i = 63; ~i; i--) {
|
||||
if (x & (1ull << i)) {
|
||||
if (a[i]) {
|
||||
x ^= a[i];
|
||||
} else {
|
||||
a[i] = x;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> x;
|
||||
|
||||
insert(x);
|
||||
}
|
||||
|
||||
for (int i = 63; ~i; i--) {
|
||||
if ((ans ^ a[i]) > ans) ans ^= a[i];
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user