lichao

Crates.iolichao
lib.rslichao
version0.1.1
created_at2025-06-02 22:09:48.916013+00
updated_at2025-06-02 22:21:47.71508+00
descriptionLi-Chao tree implementation ported from the authors competitive programming library
homepagehttps://github.com/isogenist/LiChao
repositoryhttps://github.com/isogenist/LiChao
max_upload_size
id1698419
size17,909
Isogenist (isogenist)

documentation

README

lichao

Implementation of a Li-Chao tree ported from the authors competitive programming library.

Theoretically, a Li-Chao tree should support any function which has the transcending property, but this implementation supports only lines, which are the most common use case.

Currently doesn't support adding custom-width line segments, will be added soon.

Since the performance of Li-Chao trees depends on the size of the domain, it may be preferable to use the Convex hull trick instead.

Li-Chao trees

Li-Chao trees solve the following problem class in O(log n) time:

Given a set S of functions s.t. each pair of functions can intersect at most one point (e.g. lines), efficiently implement
1. Adding a function to S
2. Answering the minimum/maximum value at f(t) for all functions f in S (i.e. \min{f \in S} f(t))

Formally, we require the functions to have the transcending property, that is, given two functions $f, g \in S$, if $f(t) = g(t)$, then either $f(x) < g(x) \forall x < t$ and $f(x) > g(x) \forall x > t$, or $f(x) > g(x) \forall x < t$ and $f(x) < g(x) \forall x > t$

Commit count: 7

cargo fmt