Advanced Re-rooting Dynamic Programming Walkthrough
Re-rooting DP is a tree-DP variant that looks intimidating at first, yet becomes very mechenical once the pattern is recognized. The following problems illustrate the key techniques.
Problem 1 – USACO 2012 FEB "Nearby Cows"
Task: for every node i compute the sum of weights of all nodes whose distance to i is at most K.
Constraints: n ...
Posted on Wed, 29 Jul 2026 16:38:52 +0000 by daf_cr
Interval DP Solution for Zuma-like Ball Elimination Problem
The elimination rule—removing consecutive identical elements when their count reaches a threshold $k$—suggests an interval dynamic programming approach. A two-dimensional DP state is insufficient because it cannot capture how the leftmost element in a segment is eventually removed. To resolve this, we introduce a third dimension that tracks how ...
Posted on Sat, 23 May 2026 20:25:04 +0000 by joukar