library_checker/graph/
directedmst.rs1use competitive::prelude::*;
2#[doc(no_inline)]
3pub use competitive::{algebra::AdditiveOperation, graph::EdgeListGraphScanner};
4
5#[verify::library_checker("directedmst")]
6pub fn directedmst(reader: impl Read, mut writer: impl Write) {
7 let s = read_all_unchecked(reader);
8 let mut scanner = Scanner::new(&s);
9 scan!(scanner, n, m, s, (graph, w): @EdgeListGraphScanner::<usize, i64>::new(n, m));
10 let res = graph
11 .minimum_spanning_arborescence::<AdditiveOperation<_>, _>(s, |u| w[u])
12 .unwrap();
13 iter_print!(writer, res.0; @it res.1);
14}