← All problemsSign in

Taxi Fare

Treeland is a country with N cities connected to each other with N-1 bidirectional roads in such a way that there is some path between every 2 cities. Because of the smooth roads, the preferred method of travel in Treeland is via taxi. When someone takes a taxi between 2 cities the driver always uses the shortest path between these 2 cities. However, the fare calculation for journeys done via tax

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