Riverland
CodeChefOpen on judge ↗
There is a country with a large river system. The cities in this country are numbered $1$ through $N$; city number $1$ is the capital. The river system forms a rooted tree such that the capital is the root. Each river connects two cities and flows towards the root. For each non-root city $i$, there is a river that flows from this city to city $p_i$. There is also a port in each city. In the count
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.
Sign in to chat with the tutor and save your progress.
Sign in to start