Tree and Extra Edge
CodeChefOpen on judge ↗
You have a rooted tree consisting of $n$ vertices. There are some weights on each edge of the tree denoted by $W_i$. The tree root is a vertex with number $1$. In this problem, you need to answer $Q$ queries. Each query is described by three values $u$, $v$, and $x$. It is guaranteed that subtrees of node $u$ and node $v$ are disjoint. You are allowed to add at most one edge of weight $x$ betwee
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