← All problemsSign in

Tangling Tree

CodeChefRating 4076Open on judge ↗

You are given an undirected tree of $N$ nodes. A positive weight $W_i$ is assigned to the node $i$ for all $1 \le i \le N$. For all $1 \le j \le N-1$, the $j$-th edge connects the nodes $u_j$ and $v_j$, and has a restriction value of $R_j$. An array $A_1, A_2, \cdots, A_N$ consisting of $N$ non-negative integers is called **valid** if: - For all $1 \le j \leq N-1$, the condition $A_{u_j}+A_{v_j}

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start