← All problemsSign in

Random Walk Queries

CodeChefRating 2938Open on judge ↗

Chef visited his native country Chefland for vacation. Chefland has $N$ towns (numbered $1$ through $N$) and $N-1$ bidirectional roads connecting the towns in such a way that it is possible to travel from each town to any other town. Chef had a series of $Q$ tasks he wanted to perform in Chefland. There are two types of tasks: - `1 u d`: Chef should make a random walk with a maximum length $d$

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