Skip to main content

OfflineLiChaoTree

Struct OfflineLiChaoTree 

Source
pub struct OfflineLiChaoTree<X, L> {
    events: Vec<LiChaoEvent<X, L>>,
    queries: usize,
}

Fields§

§events: Vec<LiChaoEvent<X, L>>§queries: usize

Implementations§

Source§

impl<X, L> OfflineLiChaoTree<X, L>
where X: Copy + Ord + RadixSortKey, L: LiChaoLine<X>,

Source

pub fn new() -> Self

Examples found in repository?
crates/library_checker/src/data_structure/line_add_get_min.rs (line 15)
12pub fn line_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (a, b) in sv!([(i32, i64); iter n]) {
17        tree.add_line((a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { a, b } => {
23                tree.add_line((a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    pp!(@lf @it tree.execute().into_iter().map(Option::unwrap));
31}
More examples
Hide additional examples
crates/library_checker/src/data_structure/segment_add_get_min.rs (line 15)
12pub fn segment_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (l, r, a, b) in sv!([(i32, i32, i32, i64); iter n]) {
17        tree.add_segment(l..r, (a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { l, r, a, b } => {
23                tree.add_segment(l..r, (a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    for result in tree.execute() {
31        if let Some(value) = result {
32            pp!(value);
33        } else {
34            pp!("INFINITY");
35        }
36    }
37}
Source

pub fn add_line(&mut self, line: L)

Examples found in repository?
crates/library_checker/src/data_structure/line_add_get_min.rs (line 17)
12pub fn line_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (a, b) in sv!([(i32, i64); iter n]) {
17        tree.add_line((a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { a, b } => {
23                tree.add_line((a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    pp!(@lf @it tree.execute().into_iter().map(Option::unwrap));
31}
Source

pub fn add_segment(&mut self, range: Range<X>, line: L)

Examples found in repository?
crates/library_checker/src/data_structure/segment_add_get_min.rs (line 17)
12pub fn segment_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (l, r, a, b) in sv!([(i32, i32, i32, i64); iter n]) {
17        tree.add_segment(l..r, (a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { l, r, a, b } => {
23                tree.add_segment(l..r, (a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    for result in tree.execute() {
31        if let Some(value) = result {
32            pp!(value);
33        } else {
34            pp!("INFINITY");
35        }
36    }
37}
Source

pub fn query_min(&mut self, x: X) -> usize

Examples found in repository?
crates/library_checker/src/data_structure/line_add_get_min.rs (line 26)
12pub fn line_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (a, b) in sv!([(i32, i64); iter n]) {
17        tree.add_line((a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { a, b } => {
23                tree.add_line((a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    pp!(@lf @it tree.execute().into_iter().map(Option::unwrap));
31}
More examples
Hide additional examples
crates/library_checker/src/data_structure/segment_add_get_min.rs (line 26)
12pub fn segment_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (l, r, a, b) in sv!([(i32, i32, i32, i64); iter n]) {
17        tree.add_segment(l..r, (a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { l, r, a, b } => {
23                tree.add_segment(l..r, (a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    for result in tree.execute() {
31        if let Some(value) = result {
32            pp!(value);
33        } else {
34            pp!("INFINITY");
35        }
36    }
37}
Source

pub fn execute(self) -> Vec<Option<L::Output>>

Examples found in repository?
crates/library_checker/src/data_structure/line_add_get_min.rs (line 30)
12pub fn line_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (a, b) in sv!([(i32, i64); iter n]) {
17        tree.add_line((a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { a, b } => {
23                tree.add_line((a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    pp!(@lf @it tree.execute().into_iter().map(Option::unwrap));
31}
More examples
Hide additional examples
crates/library_checker/src/data_structure/segment_add_get_min.rs (line 30)
12pub fn segment_add_get_min(reader: impl Read, writer: impl Write) {
13    prepare_io!(reader, writer);
14    sc!(n, q);
15    let mut tree = OfflineLiChaoTree::new();
16    for (l, r, a, b) in sv!([(i32, i32, i32, i64); iter n]) {
17        tree.add_segment(l..r, (a, b));
18    }
19    for _ in 0..q {
20        sc!(query: Query);
21        match query {
22            Query::Add { l, r, a, b } => {
23                tree.add_segment(l..r, (a, b));
24            }
25            Query::Get { x } => {
26                tree.query_min(x);
27            }
28        }
29    }
30    for result in tree.execute() {
31        if let Some(value) = result {
32            pp!(value);
33        } else {
34            pp!("INFINITY");
35        }
36    }
37}

Trait Implementations§

Source§

impl<X: Clone, L: Clone> Clone for OfflineLiChaoTree<X, L>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<X: Debug, L: Debug> Debug for OfflineLiChaoTree<X, L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<X, L> Default for OfflineLiChaoTree<X, L>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<X, L> Freeze for OfflineLiChaoTree<X, L>
where Vec<LiChaoEvent<X, L>>: Freeze,

§

impl<X, L> RefUnwindSafe for OfflineLiChaoTree<X, L>

§

impl<X, L> Send for OfflineLiChaoTree<X, L>
where Vec<LiChaoEvent<X, L>>: Send,

§

impl<X, L> Sync for OfflineLiChaoTree<X, L>
where Vec<LiChaoEvent<X, L>>: Sync,

§

impl<X, L> Unpin for OfflineLiChaoTree<X, L>
where Vec<LiChaoEvent<X, L>>: Unpin,

§

impl<X, L> UnsafeUnpin for OfflineLiChaoTree<X, L>
where Vec<LiChaoEvent<X, L>>: UnsafeUnpin,

§

impl<X, L> UnwindSafe for OfflineLiChaoTree<X, L>
where Vec<LiChaoEvent<X, L>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToArrayVecScalar for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.