← All problemsSign in

Optimise the toll collection

Byteland is a kingdom with tree topology where there are total N cities numbered from 0 to N - 1. The capital city lies at the root of the tree and has number 0. Each edge in the tree represents an undirected road between two cities. We can assume that distance of each such edge is 1. In this paragraph, we describe the current transportation toll system. There is a toll booth at capital city. Als

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