Skip to content

Commit 683e7f1

Browse files
committed
update test
1 parent c08e4dd commit 683e7f1

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
int min_left(int l, int r, const auto& f) {
22
if (T x = s[r + n]; f(x))
33
for (r--; l <= r;) {
4-
cout << "l,r:" << l << ' ' << r << endl; // 0 1
54
int u = r + 1 + n, v = __lg(min(u & -u, r - l + 1));
65
if (T y = op(s[(u - 1) >> v], x); f(y))
76
r -= 1 << v, x = y;

tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ int main() {
1515
return {int(1LL * l[0] * r[0] % mod),
1616
int((1LL * r[0] * l[1] + r[1]) % mod)};
1717
});
18+
const array<int, 2> unit = {1, 0};
1819
while (q--) {
1920
int type;
2021
cin >> type;
@@ -25,8 +26,49 @@ int main() {
2526
} else {
2627
int l, r, x;
2728
cin >> l >> r >> x;
28-
auto [slope, y_int] = st.query(l, r - 1);
29-
cout << (1LL * slope * x + y_int) % mod << '\n';
29+
r--;
30+
array<int, 2> res = st.query(l, r);
31+
{
32+
array<int, 2> walk_res = {1, 0};
33+
int idx = st.max_right(l, r,
34+
[&](const array<int, 2>& curr_line) -> bool {
35+
walk_res = curr_line;
36+
return 1;
37+
});
38+
assert(res == walk_res);
39+
assert(idx == r + 1);
40+
}
41+
{
42+
array<int, 2> walk_res = unit;
43+
int idx = st.max_right(l, r,
44+
[&](const array<int, 2>& curr_line) -> bool {
45+
walk_res = curr_line;
46+
return 0;
47+
});
48+
assert(walk_res == st.query(l, l));
49+
assert(idx == l);
50+
}
51+
{
52+
array<int, 2> walk_res = unit;
53+
int idx = st.min_left(l, r,
54+
[&](const array<int, 2>& curr_line) -> bool {
55+
walk_res = curr_line;
56+
return 1;
57+
});
58+
assert(walk_res == res);
59+
assert(idx == l - 1);
60+
}
61+
{
62+
array<int, 2> walk_res = unit;
63+
int idx = st.min_left(l, r,
64+
[&](const array<int, 2>& curr_line) -> bool {
65+
walk_res = curr_line;
66+
return 0;
67+
});
68+
assert(walk_res == st.query(r, r));
69+
assert(idx == r);
70+
}
71+
cout << (1LL * res[0] * x + res[1]) % mod << '\n';
3072
}
3173
}
3274
return 0;

0 commit comments

Comments
 (0)