← All problemsSign in

The Two Dear Friends of Chefland

Chef has two dear friends named Shivansh and Vivek living in Chefland. As you might know, Chefland is a country of $N$ cities, where there are $N - 1$ roads connecting two cities, such that it is possible to go to any city from any other city using nothing but these roads. Ever since the Industrial Revolution, every city of chefland became a centre for automobile industries, where the $i$-th city

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