Skip to content

Refactor CHT #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Rename methods of Li-Chao tree
  • Loading branch information
hitonanode committed Sep 20, 2021
commit e75dba676022369d22d40dbf90243d516a059eef
6 changes: 3 additions & 3 deletions convex_hull_trick/li_chao_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Li-Chao tree
// init() : set x's where we will execute get(x) queries
// add_segment(l, r, a, b): update by ax + b in [l, r)
// insert_segment(l, r, a, b): update by ax + b in [l, r)
// get(x): get min
template <class T, class T_MP> struct li_chao_tree {
int _n, _head;
Expand Down Expand Up @@ -78,12 +78,12 @@ template <class T, class T_MP> struct li_chao_tree {
}
}

void add_line(T a, T b, int idx = -1) {
void insert_line(T a, T b, int idx = -1) {
il = 0, ir = _n;
if (il >= ir) return;
_rec(1, 0, _head, _Line{a, b, idx, true});
}
void add_segment(T xl, T xr, T a, T b, int idx = -1) {
void insert_segment(T xl, T xr, T a, T b, int idx = -1) {
il = std::lower_bound(xs.begin(), xs.end(), xl) - xs.begin();
ir = std::lower_bound(xs.begin(), xs.end(), xr) - xs.begin();
if (il >= ir) return;
Expand Down
2 changes: 1 addition & 1 deletion convex_hull_trick/li_chao_tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ vector<long long> xs;
li_chao_tree<long long, __int128> tree;
tree.init(xs); // xs が昇順である必要はない

tree.add_segment(l, r, a, b, 0); // chmin by ax + b in [l, r)
tree.insert_segment(l, r, a, b, 0); // chmin by ax + b in [l, r)

ret = tree.get(x);
cout << ret.minval << endl;
Expand Down
2 changes: 1 addition & 1 deletion convex_hull_trick/test/li_chao_tree.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main() {

for (auto q : qs) {
tie(tp, l, r, a, b) = q;
if (tp == 0) tree.add_segment(l, r, a, b, 0);
if (tp == 0) tree.insert_segment(l, r, a, b, 0);
if (tp == 1) {
auto ret = tree.get(l);
if (ret.is_valid) {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy