Passing Through!
You are given a tree with $N$ vertices, where the $i^{th}$ vertex has color $A_i$. We say that an edge of this tree *separates* color $C$ if, upon deleting this edge from the tree, **both** obtained components contain **at least one** vertex having color $C$. The *value* of an edge is defined as the sum of all the colors it *separates*. For example, if an edge separates colors $\{1, 4, 7, 13\}$,
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start