← All problemsSign in

F - Beautiful Walk

You are given a directed graph with $n$ vertices and $m$ edges. A walk is defined as a sequence of vertices, such that there is an edge from every vertex in the walk to the next vertex in the walk. Formally, a walk with $t$ edges is a sequence $v_1, v_2, \ldots v_{t+1}$, where for each $1 \leq i \leq t$, there is an edge from $v_i$ to $v_{i + 1}$. The vertices $v_i$ of a walk do *not* have

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