-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGauss.cpp
More file actions
49 lines (42 loc) · 796 Bytes
/
Copy pathGauss.cpp
File metadata and controls
49 lines (42 loc) · 796 Bytes
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
#include<bits/stdc++.h>
using namespace std;
struct gauss {
int b, size;
vector <int> basis;
gauss() {}
gauss(int b) : b(b), size(0) {
basis.assign(b + 1, 0);
}
void insert(long long x) {
for (int i = b; i >= 0; i--) {
if (((x >> i) & 1) == 0) continue;
if (!basis[i]) {
basis[i] = x;
size++;
break;
} else x ^= basis[i];
}
}
bool is_part(long long x) {
for (int i = b; i >= 0; i--) {
if (((x >> i) & 1) == 0) continue;
x ^= basis[i];
}
return x == 0;
}
vector <int> get_elements() {
vector <int> v = {0};
for (int i = 0; i <= b; i++) {
if (basis[i] == 0) continue;
int sz = v.size();
for (int j = 0; j < sz; j++) v.push_back(v[j] ^ basis[i]);
}
return v;
}
};
int main() {
int b;
cin >> b;
// no of bits
gauss g(b);
}