CF1787G Colorful Tree Again

Description

An edge-weighted tree of $ n $ nodes is given with each edge colored in some color. Each node of this tree can be blocked or unblocked, all nodes are unblocked initially. A simple path is a path in a graph that does not have repeating nodes. The length of a path is defined as the sum of weights of all edges on the path. A path is good when it is a simple path consisting of edges of the same color $ c $ , all edges of color $ c $ are on this path, and every node on the path is unblocked. You need to operate $ 2 $ kinds of queries: 1. block a node, 2. unblock a node. After each query, print the maximum length among all good paths. If there are no good paths, print $ 0 $ .

Input Format

N/A

Output Format

N/A