Skip to content

Commit 182caaf

Browse files
authored
previous code is RTE when n=0
1 parent d305a6b commit 182caaf

File tree

1 file changed

+2
-1
lines changed
  • library/data_structures_[l,r]/seg_tree_uncommon

1 file changed

+2
-1
lines changed

library/data_structures_[l,r]/seg_tree_uncommon/init.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
tree(const vector<T>& a, F op):
33
n(sz(a)), op(op), s(2 * n) {
44
rep(i, 0, n) s[i + n] = a[i];
5-
for (int i = n; --i;) s[i] = op(s[2 * i], s[2 * i + 1]);
5+
for (int i = n - 1; i >= 1; i--)
6+
s[i] = op(s[2 * i], s[2 * i + 1]);
67
}

0 commit comments

Comments
 (0)