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

:warning: verify/AtCoder/abc222f/src/main.rs

Depends on

Code

// https://atcoder.jp/contests/abc222/tasks/abc222_f

use algebra::{Commutative, Monoid};
use proconio::{fastout, input, marker::Usize1};
use rerooting::Rerooting;
use rustc_hash::FxHashMap;

#[derive(Debug)]
pub struct MaxMonoid {}
impl Monoid for MaxMonoid {
    type Target = u64;
    fn id_element() -> Self::Target {
        0
    }
    fn binary_operation(a: &Self::Target, b: &Self::Target) -> Self::Target {
        *a.max(b)
    }
}
impl Commutative for MaxMonoid {}

#[fastout]
fn main() {
    input! {
        n: usize,
        a_b_c: [(Usize1, Usize1, u64); n - 1],
        d: [u64; n],
    }
    let mut graph = vec![vec![]; n];
    for (a, b, _) in &a_b_c {
        graph[*a].push(*b);
        graph[*b].push(*a);
    }
    let edge_cost: FxHashMap<(usize, usize), u64> = a_b_c
        .into_iter()
        .map(|(a, b, c)| ((a.min(b), a.max(b)), c))
        .collect();
    let add_root = |subtree: &u64, subtree_root: usize, new_root: usize| {
        let edge_cost = edge_cost
            .get(&(subtree_root.min(new_root), subtree_root.max(new_root)))
            .unwrap();
        subtree.max(&d[subtree_root]) + edge_cost
    };
    let rerooted = Rerooting::<MaxMonoid, _>::new(&graph, add_root);
    for i in 0..n {
        println!("{}", rerooted.get_ans(i));
    }
}
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