MillenniumOA #2
Warehouse Tree Compatible Pairs
Estimated HardStatement and editorial — judging is being prepared
Topics (AI-labelled)Binary SearchTree Traversal
A network of warehouses is an undirected rooted weighted tree with warehouse_nodes nodes rooted at warehouse 1. Each node has a value val[v]. A pair (u, v) is compatible iff:
uis an ancestor ofvin the tree.distance(u, v) ≤ val[v].
Count compatible pairs.
Example: with the input from the OA, the answer is 5.
Constraints
- 1 ≤ warehouse_nodes ≤ 1.5·10⁵
- 1 ≤ warehouse_weight[i] ≤ 10⁴
- 1 ≤ val[i] ≤ 10⁹
Editorial
Loading solution…