Problem 2378 · Medium
Post-order tree DP on two states per node: free or matched to one child, with empty selections allowed.
Open the interactive visualisation