Ezvor

3967. Finish Time of Tasks II

HardArray Preparing judge… LeetCode
ArrayDynamic ProgrammingTreeDepth-First Search

Hints

Hint 1
Rooting the tree at different nodes only changes which neighbors are treated as children.
Hint 2
For every directed edge u -> v, compute the finish time of the component on the v side when u is considered its parent.
Hint 3
Use rerooting DP: after computing values from children to parent, propagate values from parent to children.
Hint 4
For each node, you only need the minimum and maximum finish times among all neighboring components to compute its finish time as the root.