← All problemsSign in

Markers on a Tree (Easy)

CodeChefRating 1967Open on judge ↗

**This is the easy version of the problem. Here, you only need to find $f(S)$.** For a tree $T$ consisting of $N$ labelled nodes, labelled $1$ through $N$; consider having $2$ markers, marker $A$ initially located at node $1$ and marker $B$ located at node $N$. In one move, you can move **exactly** one of the $2$ markers from it's current node to an adjacent node. A node is considered visited if

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