Skip to content

Commit fcb8967

Browse files
authored
Optimize wavelet_matrix constructor logic
1 parent 6f3a198 commit fcb8967

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/data_structures_[l,r)/seg_tree_uncommon/wavelet_matrix.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ struct wavelet_matrix {
1414
wavelet_matrix(vector<ull> a, ull max_val):
1515
n(sz(a)), bv(bit_width(max_val), {{}}) {
1616
for (int h = sz(bv); h--;) {
17-
int i = 0;
1817
vector<bool> b(n);
18+
rep(i, 0, n) b[i] = (~a[i] >> h) & 1;
1919
ranges::stable_partition(a,
20-
[&](ull x) { return b[i++] = (~x >> h) & 1; });
20+
[&](ull x) { return (~x >> h) & 1; });
2121
bv[h] = b;
2222
}
2323
}

0 commit comments

Comments
 (0)