← All problemsSign in

Precious Stones

CodeChefRating 2775Open on judge ↗

Chefland consists of $N$ villages connected by $N-1$ roads in such a way that the road network is a tree, i.e. there are no cycles and each village is reachable from any other village. A well known legend says that in the middle of each road, there is a hidden precious stone. There are $K$ different colours of stones, conveniently numbered $1$ through $K$, and for each road, we also know the colou

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