procon_lib_rs

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub CoCo-Japan-pan/procon_lib_rs

:heavy_check_mark: verify/AOJ/dsl_2f_lazy_seg/src/main.rs

Depends on

Code

// verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/all/DSL_2_F

use lazy_segtree::LazySegTree;
use proconio::{fastout, input};

#[derive(Clone, Debug, PartialEq, Eq)]
struct MyMap {
    update: Option<u32>,
}
impl algebra::Action for MyMap {
    type Target = u32;
    fn id_action() -> Self {
        MyMap { update: None }
    }
    fn composition(&mut self, rhs: &Self) {
        if let Some(x) = rhs.update {
            self.update = Some(x);
        }
    }
    fn apply(&self, target: &mut Self::Target) {
        if let Some(x) = self.update {
            *target = x;
        }
    }
}

#[derive(Debug)]
struct MinMonoid {}
impl algebra::Monoid for MinMonoid {
    type Target = u32;
    fn id_element() -> Self::Target {
        u32::MAX
    }
    fn binary_operation(a: &Self::Target, b: &Self::Target) -> Self::Target {
        *a.min(b)
    }
}

struct RmqRuq {}
impl algebra::ActionMonoid for RmqRuq {
    type M = MinMonoid;
    type A = MyMap;
}

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
    }
    let mut lazy_seg = LazySegTree::<RmqRuq>::from(vec![(1_u32 << 31) - 1; n]);
    for _ in 0..q {
        input! {
            t: u32,
        }
        if t == 0 {
            input! {
                s: usize,
                t: usize,
                x: u32,
            }
            let map = MyMap { update: Some(x) };
            lazy_seg.apply_range(s..=t, &map);
        } else {
            input! {
                s: usize,
                t: usize,
            }
            println!("{}", lazy_seg.prod(s..=t));
        }
    }
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.13.9/x64/lib/python3.13/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.9/x64/lib/python3.13/site-packages/onlinejudge_verify/languages/rust.py", line 288, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page