Skip to content

Commit c7070a9

Browse files
committed
fix
1 parent 20c104b commit c7070a9

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

library/math/matrix_related/xor_basis_unordered_intersection.hpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
//! https://github.com/suisen-cp/cp-library-cpp/blob/main/library/linear_algebra/xor_base.hpp
44
//! @time O(32^2) or O(64^2);
55
//! @space O(32) or O(64)
6-
template<class T>
7-
basis<T> intersection(const basis<T>& u,
8-
const basis<T>& v) {
9-
vector<pair<T, T>> w(sz(u.b));
6+
basis intersection(const basis& u, const basis& v) {
7+
vector<pii> w(sz(u.b));
108
rep(i, 0, sz(w)) w[i] = {u.b[i], u.b[i]};
11-
basis<T> res;
12-
for (T e : v.b) {
13-
T s = 0;
9+
basis res;
10+
for (int e : v.b) {
11+
int s = 0;
1412
for (auto [x, y] : w)
1513
if ((e ^ x) < e) e ^= x, s ^= y;
1614
if (e) w.emplace_back(e, s);

tests/library_checker_aizu_tests/math/xor_basis_intersection.test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "../../../library/math/matrix_related/xor_basis_unordered_intersection.hpp"
55
// checking the condition: for 0 <= i < j < sz(b):
66
// (bit_floor(b[i]) & b[j]) == 0
7-
void check_condition(const basis<int>& b) {
7+
void check_condition(const basis& b) {
88
int n = sz(b.b);
99
int or_bits = 0;
1010
for (int i = n - 1; i >= 0; i--) {
@@ -20,7 +20,7 @@ int main() {
2020
while (t--) {
2121
int n;
2222
cin >> n;
23-
basis<int> basis1;
23+
basis basis1;
2424
for (int i = 0; i < n; i++) {
2525
int val;
2626
cin >> val;
@@ -29,14 +29,14 @@ int main() {
2929
check_condition(basis1);
3030
int m;
3131
cin >> m;
32-
basis<int> basis2;
32+
basis basis2;
3333
for (int j = 0; j < m; j++) {
3434
int val;
3535
cin >> val;
3636
assert(basis2.insert(val));
3737
}
3838
check_condition(basis2);
39-
basis<int> inter = intersection<int>(basis1, basis2);
39+
basis inter = intersection(basis1, basis2);
4040
check_condition(inter);
4141
cout << sz(inter.b) << " ";
4242
for (int val : inter.b) cout << val << " ";

0 commit comments

Comments
 (0)