Problem 3515 · Hard

Shortest Path in a Weighted Tree

Given a weighted tree rooted at node 1, process a list of queries that either change the weight of one edge or ask for the distance from the root to a node. Return the answers to the distance queries in order.

Open the interactive visualisation