Skip to content

Commit 99426ff

Browse files
committed
use / 2 for arithmetic halving, keep >> 1 for bit manipulation
1 parent 5ae36e5 commit 99426ff

17 files changed

Lines changed: 32 additions & 34 deletions

library/convolution/min_plus_convolution_convex_and_arbitrary.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ vi min_plus(const vi& convex, const vi& arbitrary) {
1212
auto dnc = [&](this auto&& dnc, int res_le, int res_ri,
1313
int arb_le, int arb_ri) {
1414
if (res_le >= res_ri) return;
15-
int mid_res = (res_le + res_ri) >> 1;
15+
int mid_res = (res_le + res_ri) / 2;
1616
int op_arb = arb_le;
1717
rep(i, arb_le, min(mid_res + 1, arb_ri)) {
1818
int j = mid_res - i;

library/data_structures_[l,r)/seg_tree_midpoint.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
//! https://codeforces.com/blog/entry/112755
33
int split(int tl, int tr) {
44
int pw2 = bit_floor(tr - tl + 0u);
5-
return min(tl + pw2, tr - (pw2 >> 1));
5+
return min(tl + pw2, tr - pw2 / 2);
66
}

library/data_structures_[l,r)/uncommon/deque_op.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ template<class T, class F> struct deq {
1010
F op;
1111
vector<dt> l, r;
1212
deq(const vector<T>& a, F op): op(op) {
13-
rebuild(a, sz(a) >> 1);
13+
rebuild(a, sz(a) / 2);
1414
}
1515
T query() {
1616
if (empty(l)) return r.back()[1];
@@ -33,7 +33,7 @@ template<class T, class F> struct deq {
3333
vector<T> a(sz(l));
3434
ranges::transform(l, rbegin(a),
3535
[](dt& x) { return x[0]; });
36-
rebuild(a, sz(a) >> 1);
36+
rebuild(a, sz(a) / 2);
3737
}
3838
r.pop_back();
3939
}
@@ -46,7 +46,7 @@ template<class T, class F> struct deq {
4646
vector<T> a(sz(r));
4747
ranges::transform(r, begin(a),
4848
[](dt& x) { return x[0]; });
49-
rebuild(a, (sz(a) + 1) >> 1);
49+
rebuild(a, (sz(a) + 1) / 2);
5050
}
5151
l.pop_back();
5252
}

library/data_structures_[l,r]/seg_tree_midpoint.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
//! @endcode
77
int split(int tl, int tr) {
88
int pw2 = bit_floor(tr - tl + 1u);
9-
return min(tl + pw2 - 1, tr - (pw2 >> 1));
9+
return min(tl + pw2 - 1, tr - pw2 / 2);
1010
}

library/math/count_paths/count_paths_triangle.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ vl divide_and_conquer(vl h, vl bottom) {
1515
int n = sz(h);
1616
if (n == 0) return {};
1717
if (n == 1) return vl(h[0], bottom[0]);
18-
int mid = n >> 1;
18+
int mid = n / 2;
1919
auto rect_left =
2020
divide_and_conquer(vl(begin(h), begin(h) + mid),
2121
vl(begin(bottom), begin(bottom) + mid));

library/strings/manacher/longest_from_index.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! @time O(n)
1010
//! @space O(n)
1111
vi longest_from_index(pal_query& pq) {
12-
int n = (sz(pq.man) + 1) >> 1;
12+
int n = (sz(pq.man) + 1) / 2;
1313
vector longest(n, n - 1);
1414
for (int i = n - 2; i >= 0; i--) {
1515
longest[i] = min(longest[i + 1] + 1, n - 1);

library/strings/manacher/longest_palindrome_query.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ struct longest_pal_query {
5252
});
5353
int best_center =
5454
rmq.query(2 * l + pal_len - 1, 2 * r - pal_len);
55-
return {(best_center + 1 - pal_len) >> 1, pal_len};
55+
return {(best_center + 1 - pal_len) / 2, pal_len};
5656
}
5757
};

library/strings/manacher/manacher.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ vi manacher(const auto& s) {
2222
rep(i, 0, 2 * n - 1) {
2323
int r = i <= 2 * (p - man[p])
2424
? p - max(man[2 * p - i], man[p])
25-
: i >> 1;
25+
: i / 2;
2626
man[i] = i - r;
2727
while (
2828
man[i] > 0 && r + 1 < n && s[man[i] - 1] == s[r + 1])

tests/library_checker_aizu_tests/data_structures/bit_ordered_set.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int main() {
2222
auto get_compressed_idx = [&](int val) -> int {
2323
int l = 0, r = sz(compress);
2424
while (l + 1 < r) {
25-
int m = (l + r) >> 1;
25+
int m = (l + r) / 2;
2626
if (compress[m] <= val) l = m;
2727
else r = m;
2828
}

tests/library_checker_aizu_tests/data_structures/kth_smallest_pst.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main() {
1414
for (int& val : arr) {
1515
int start = 0, end = sz(sorted);
1616
while (start + 1 < end) {
17-
int mid = (start + end) >> 1;
17+
int mid = (start + end) / 2;
1818
if (sorted[mid] <= val) start = mid;
1919
else end = mid;
2020
}

0 commit comments

Comments
 (0)