You are given a weighted undirected tree on nnn vertices and a list of qqq updates. Each update changes the weight of one edge. The task is to output the diameter of the tree after each update.
You are given a weighted undirected tree on nnn vertices and a list of qqq updates. Each update changes the weight of one edge. The task is to output the diameter of the tree after each update. (The distance between two vertices is the sum of the weights on the unique simple path that connects them. The diameter is the largest of all those distances.)
(图片来源网络,侵删)