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/yukicoder/no_789_dynamic/src/main.rs

Depends on

Code

// verification-helper: PROBLEM https://yukicoder.me/problems/no/789

use algebra::Monoid;
use dynamic_segtree::DynamicSegTree;
use proconio::{fastout, input};

#[derive(Debug)]
struct SumMonoid;
impl Monoid for SumMonoid {
    type Target = usize;
    fn id_element() -> Self::Target {
        0
    }
    fn binary_operation(a: &Self::Target, b: &Self::Target) -> Self::Target {
        a + b
    }
}

#[fastout]
fn main() {
    input! {
        n: usize,
        t_x_y: [(u8, usize, usize); n],
    }
    let mut seg = DynamicSegTree::<SumMonoid>::new(1000_000_010);
    let mut ans = 0;
    for (t, x, y) in t_x_y {
        if t == 0 {
            let pre_val = seg.get(x);
            seg.set(x, pre_val + y);
        } else {
            ans += seg.prod(x..=y);
        }
    }
    println!("{}", ans);
}
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