← All problemsSign in

City Friends

There is a state with $n$ (numbered $1$ to $n$) cities and $m$ (each road is a two way road connecting 2 cities). You are in the state and plan to visit your two close friends Harry and Ron. But there is a problem. In the middle of each road, there is a toll booth, where you need to pay a certain amount of money to go past. As you know, you are short on cash but nothing can stop you from visit

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