Skip to content

Commit 40cd17a

Browse files
committed
nit
1 parent cede36a commit 40cd17a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

library/data_structures/seg_tree_uncommon/wavelet_bit_vec.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ using ull = uint64_t;
1010
struct bit_vec {
1111
vector<pair<ull, int>> b;
1212
bit_vec(const vector<bool>& a): b(sz(a) / 64 + 1) {
13-
rep(i, 0, sz(a)) b[i >> 6].first |= ull(a[i])
14-
<< (i & 63);
15-
rep(i, 0, sz(b) - 1) b[i + 1].second =
16-
popcount(b[i].first) + b[i].second;
13+
rep(i, 0, sz(a)) {
14+
auto& [x, y] = b[i >> 6];
15+
x |= ull(a[i]) << (i & 63), y += a[i];
16+
}
17+
rep(i, 1, sz(b)) b[i].second += b[i - 1].second;
1718
}
1819
int cnt(int r) {
1920
auto [x, y] = b[r >> 6];
20-
return y + popcount(x & ((1ULL << (r & 63)) - 1));
21+
return y - popcount(x & -1ULL << (r & 63));
2122
}
2223
};

0 commit comments

Comments
 (0)