Skip to content

Commit 807a3c7

Browse files
fix bugs for lazy_segment_tree and it's test
1 parent 5b61ed8 commit 807a3c7

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

.github/workflows/testLibrary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030
- name: Test
3131
run: |
3232
cd library
33-
./test.exe --gtest_repeat=8
33+
./test.exe --gtest_repeat=20

library/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ STDCXX ?= c++14
22

33
CXX ?= g++
44

5-
CXXFLAGS = -Wall -Wextra -g -I. -MMD -std=$(STDCXX)
5+
CXXFLAGS = -Wall -Wextra -g -I. -MMD -std=$(STDCXX) -O2
66

77
TARGET = test.exe
88

library/mrpython/lazy_segment_tree.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class lazy_segment_tree {
103103
n(len),
104104
lazyInit(lazyInitVal),
105105
mergeData(mergeDataFun),
106+
operate(OperateFun),
106107
mergeLazy(mergeTagFun) {
107108
build();
108109
}

library/test/lazy_segment_tree/lazy_segment_tree_add_add.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ TEST(lazy_segment_tree, add) {
1919
if (l > r) std::swap(l, r);
2020
assert(l < r + 1);
2121
if (operator_dist(gen)) {
22-
int ans = std::accumulate(a.begin() + l, a.begin() + r + 1, (unsigned)0);
22+
unsigned ans =
23+
std::accumulate(a.begin() + l, a.begin() + r + 1, (unsigned)0);
2324
EXPECT_EQ(tree.get(l, r + 1), ans);
2425
} else {
2526
unsigned value = val_dist(gen);
26-
for (std::size_t i = l; i < r; ++i) a[i] += value;
27-
tree.set(l, r, value);
27+
for (std::size_t i = l; i < r + 1; ++i) a[i] += value;
28+
tree.set(l, r + 1, value);
2829
}
2930
}
3031
}

0 commit comments

Comments
 (0)