aizu_online_judge/grl/
grl_2_b.rs

1use competitive::prelude::*;
2#[doc(no_inline)]
3pub use competitive::{
4    algebra::AdditiveOperation,
5    graph::{EdgeListGraph, EdgeListGraphScanner},
6};
7
8#[verify::aizu_online_judge("GRL_2_B")]
9pub fn grl_2_b(reader: impl Read, mut writer: impl Write) {
10    let s = read_all_unchecked(reader);
11    let mut scanner = Scanner::new(&s);
12    scan!(scanner, vs, es, root, (graph, w): @EdgeListGraphScanner::<usize, i64>::new(vs, es));
13    let res = graph.minimum_spanning_arborescence::<AdditiveOperation<_>, _>(root, |u| w[u]);
14    writeln!(writer, "{}", res.unwrap().0).ok();
15}