Problem 3575 · Hard

Maximum Good Subtree Score

A tree DP keeps, for each subtree, the best score for every set of used digits, merging children with bitmask unions.

Open the interactive visualisation