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/yosupo/vertex_add_path_sum/src/main.rs

Depends on

Code

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

use fenwick_tree::FenwickTree;
use hld::{Path, HLD};
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        a: [u64; n],
        u_v: [(usize, usize); n - 1],
    }
    let mut graph = vec![vec![]; n];
    for (u, v) in u_v {
        graph[u].push(v);
        graph[v].push(u);
    }
    let hld = HLD::new(graph, 0);
    let mut ft = FenwickTree::new(n, 0_u64);
    for i in 0..n {
        ft.add(hld.hld_in[i], a[i]);
    }
    for _ in 0..q {
        input! {
            t: usize,
        }
        if t == 0 {
            input! {
                p: usize,
                x: u64,
            }
            ft.add(hld.hld_in[p], x);
        } else {
            input! {
                u: usize,
                v: usize,
            }
            let mut ans = 0;
            for path in hld.path(u, v, true) {
                match path {
                    Path::Ascending(l, r) | Path::Descending(l, r) => {
                        ans += ft.sum(l..r);
                    }
                }
            }
            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