Problem 3939 · Hard

Count Non Adjacent Subsets in a Rooted Tree

Process the tree bottom-up, tracking for each node the subset counts by sum modulo k with and without the node picked.

Open the interactive visualisation