report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
Module Exchange labels DP

Exchange labels DP

**Frequency: 3/10** In certain cases, the number of dynamic programming (DP) states can be too large to store in memory. To overcome this challenge, we employ the technique of "exchange labels." For instance, consider a DP state represented as $f(a, b) = c$, where $a$, $b$, and $c$ are positive integers. When the values of $a$ and $b$ are too large (e.g., $a \le 1000$ and $b \le 10^9$), solving the problem becomes impractical due to memory constraints. However, if we find that the constraint for $c$ is smaller (e.g., $c \le 1000$), we can exchange the labels by substituting $b$ with $c$. This transformation results in a new state, $f(a, c) = b'$, which reduces the number of DP states to a manageable level, allowing us to solve the problem effectively within the available memory.

Problems

Knapsack 4 282 / 356 1400
Longest common subsequence 2 161 / 263 1600

Graph

  • Shortest path
  • 0-1 BFS / Dial's algorithm
  • Multisource BFS / Dijkstra
  • DAG / Topological sort

Data structure

  • Introduction to Segment Tree and Binary Indexed Tree
  • Sparse table
  • Monotonic queue

Tree

  • Lowest common ancestor (LCA)
  • Euler tour

Dynamic Programming

  • Bitmask DP
  • Exchange labels DP
  • Game DP

Math

  • Introduction to combinatorics
  • Inclusion-exclusion principle