← All problemsSign in

Mex Tree (Min)

CodeChefRating 1862Open on judge ↗

**The problem is nearly identical to Mex Tree (Max Version) except here you must find the minimum possible score**. You have a tree with $N$ vertices. A tree is a connected undirected acyclic graph on $N$ vertices with $N - 1$ edges. You want to assign **distinct labels** to the vertices of the tree. You will choose a permutation $P$ of the integers $[0, N - 1]$ and then assign the vertex $X$ a

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