• i. DP Foundations: A DP is a shortest/longest path or a sum over paths in an acyclic state graph.
  • ii. Knapsack and Subset Sum: Items with cost and value , capacity .
  • iii. Classic DP Problems: The classic problems are worth knowing less for themselves than for the patterns they introduce:
  • iv. LIS, LCS and Edit Distance: Three DPs on sequences with a lot of structure:
  • v. Interval DP: State = a contiguous range .
  • vi. Bitmask DP: The state contains a subset of a small ground set (–), stored as an integer.
  • vii. Broken Profile DP: DP over a grid with one small dimension (up to 10–20), where the state is the boundary between processed and unprocessed cells.
  • viii. Digit DP: Count (or sum, or optimise) over integers in (up to or given as strings of digits) satisfying a property computed digit by digit.
  • ix. Tree DP and Rerooting: State = a subtree (plus a few flags about its root).
  • x. Dynamic DP: If a DP’s transition from the previous state is linear in a semiring (, , , ), then the DP is a product of small matrices, and a segment tree over the mat
  • xi. DAG and Expected-Value DP: Every DP is a computation over a DAG of states.
  • xii. Counting DP Techniques: Techniques for counting objects (mod a prime) where a direct DP would need too much state.
  • xiii. Matrix Exponentiation DP: If the state vector evolves by a fixed linear map, , then and up to costs for states.
  • xiv. Convex Hull Trick: For transitions , each earlier state is a line and the query is the lower envelope at .
  • xv. Divide and Conquer Optimization: For layered DPs (“split the array into segments”), if the optimal is nondecreasing in , compute one layer in by divide
  • xvi. Knuth-Yao Optimization: Interval DPs run in instead of when the optimal split satisfies
  • xvii. Monotone Queue, 1D1D and SMAWK: Three tools for :
  • xviii. Aliens Trick: Also called WQS binary search or Lagrangian relaxation (IOI 2016 “Aliens”).
  • xix. Slope Trick: When the DP state is a convex piecewise-linear function with integer breakpoints, store it as its minimum value plus two heaps of breakpoints: