This documentation is automatically generated by online-judge-tools/verification-helper
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/vertex_add_subtree_sum
use fenwick_tree::FenwickTree;
use hld::HLD;
use proconio::{fastout, input};
#[fastout]
fn main() {
input! {
n: usize,
q: usize,
a: [i64; n],
p: [usize; n - 1],
}
let mut graph = vec![vec![]; n];
for (i, &j) in p.iter().enumerate() {
graph[i + 1].push(j);
graph[j].push(i + 1);
}
let hld = HLD::new(graph, 0);
let mut ft = FenwickTree::new(n, 0);
for (i, &x) in a.iter().enumerate() {
ft.add(hld.hld_in[i], x);
}
for _ in 0..q {
input! { t: usize }
match t {
0 => {
input! { u: usize, x: i64 }
ft.add(hld.hld_in[u], x);
}
1 => {
input! { u: usize }
let (l, r) = hld.subtree(u, true);
println!("{}", ft.sum(l..r));
}
_ => unreachable!(),
}
}
}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