Function solve_01_on_tree
Source pub fn solve_01_on_tree(
n: usize,
c01: impl Fn(usize) -> (usize, usize),
root: usize,
parent: impl Fn(usize) -> usize,
) -> (usize, Vec<usize>)
crates/library_checker/src/tree/rooted_tree_topological_order_with_minimum_inversions.rs (
line 13)
6pub fn rooted_tree_topological_order_with_minimum_inversions(
7 reader: impl Read,
8 mut writer: impl Write,
9) {
10 let s = read_all_unchecked(reader);
11 let mut scanner = Scanner::new(&s);
12 scan!(scanner, n, p: [usize; n - 1], c: [usize; n], d: [usize; n]);
13 let (cost, ord) = solve_01_on_tree(n, |u| (c[u], d[u]), 0, |u| p[u - 1]);
14 iter_print!(writer, cost; @it ord);
15}