Subtree Coloring
You have a tree with $N$ nodes rooted at node $1$. You want to color each node of the tree either red or blue. A coloring of the tree is considered to be *good* if for **every** subtree, the absolute difference between the number of red and blue nodes in that subtree is at most $1$. Find the number of good colorings of the tree. The count can be large, so print it modulo $10^9+7$. ### Input -
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