MillenniumOA #2
Warehouse Tree Compatible Pairs
估计困难评测数据准备中,可先阅读题面
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⁹