← All problemsSign in

Bit Twister on a Tree

CodeChefRating 2986Open on judge ↗

You are given a rooted tree consisting of n nodes, numbered 1 through n. Each of the nodes has an integer Ai assigned to it. Let's define children(v) as a sequence of the children of v placed in the increasing order of their ids. Let's define children(v, d) as the following: - children(v, 0) = [v] - children(v, 1) = children(v) - children(v, d) = children(children(v)[1], d - 1) + children(c

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