library-rs

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

View the Project on GitHub naoya675/library-rs

:heavy_check_mark: verification/library-checker/vertex_add_path_sum/src/main.rs

Depends on

Code

// verification-helper: PROBLEM https://judge.yosupo.jp/problem/vertex_add_path_sum

use proconio::input;

use euler_tour::EulerTour;
use fenwick_tree::FenwickTree;

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024)
        .spawn(actual_main)
        .unwrap()
        .join()
        .unwrap();
}

fn actual_main() {
    input! {
        n: usize,
        q: usize,
        a: [i64; n],
        uv: [(usize, usize); n - 1],
    }
    let mut et = EulerTour::<usize>::new(n);
    for (u, v) in uv {
        et.add_edge(u, v, 0);
        et.add_edge(v, u, 0);
    }
    et.init(0);
    let mut ft = FenwickTree::<i64>::new(n + n);
    for i in 0..n {
        let index = et.index(i);
        ft.add(index.0, a[i]);
        ft.add(index.1, -a[i]);
    }
    for _ in 0..q {
        input! { query: usize, }
        match query {
            0 => {
                input! { p: usize, x: i64, }
                let index = et.index(p);
                ft.add(index.0, x);
                ft.add(index.1, -x);
            }
            1 => {
                input! { u: usize, v: usize, }
                let mut res = 0;
                et.for_each(u, v, |l, r| res += ft.sum(l, r));
                println!("{}", res);
            }
            _ => unreachable!(),
        }
    }
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.12/x64/lib/python3.11/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.11.12/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/rust.py", line 288, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page