← All problemsSign in

Tree Game

CodeChefRating 2654Open on judge ↗

There are $N$ cities numbered from $1$ to $N$, connected by $(N-1)$ roads such that every city is reachable from every other city (they form a tree structure). The $i^{th}$ city has a population $P_i$. Alice and Bob are initially standing at cities $A$ and $B$ respectively. They decide to play a game, such that, at every turn: - First, Alice makes a move by moving to some adjacent city **unvisite

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