Game on Tree
CodeChefOpen on judge ↗
You are given a tree with $n$ vertices numbered $1, 2, \ldots, n$. There are two players Alice and Bob who play a game on this tree, taking turns alternatively. Alice starts. In their turn, a participant has to remove a leaf (and the edge adjacent to it) from the tree. A leaf is a node with degree $1$. Please note that the tree changes with the game progressing, and a node which is not a leaf in
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