2020-06-03 19:14:28 +00:00
|
|
|
# Gold - Dynamic Programming (DP)
|
|
|
|
Author: Michael Cao
|
2020-06-03 14:17:07 +00:00
|
|
|
|
2020-06-03 19:14:28 +00:00
|
|
|
## Prerequisites
|
2020-06-03 19:34:43 +00:00
|
|
|
Assumes familiarity with prefix sums, recursion, Bit Operations (for Bitmask DP), and Trees (for Tree DP).
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Introduction to DP
|
|
|
|
* CPH Chapter 7
|
2020-06-03 19:24:44 +00:00
|
|
|
* [Topcoder DP](https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/)
|
|
|
|
* [HackerRank DP](https://www.hackerrank.com/topics/dynamic-programming)
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Classical DP Problems
|
|
|
|
Tutorials for most problems (excluding USACO) can be found on Chapter 7 of CPH.
|
|
|
|
* Knapsack
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Unbounded](https://www.hackerrank.com/challenges/unbounded-knapsack/problem)
|
|
|
|
* [0/1](https://www.hackerrank.com/contests/srin-aadc03/challenges/classic-01-knapsack/problem)
|
|
|
|
* [Large Capacity + Small Values](https://atcoder.jp/contests/dp/tasks/dp_e)
|
|
|
|
* [Talent Show](http://www.usaco.org/index.php?page=viewproblem2&cpid=839)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Longest Increasing Subsequence
|
2020-06-03 19:23:34 +00:00
|
|
|
* [LIS in Quadratic Time](https://leetcode.com/problems/longest-increasing-subsequence/)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Try to improve to $O(NlogN)$.
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Sort It Out](http://www.usaco.org/index.php?page=viewproblem2&cpid=865)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Coin Change
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Unordered](https://cses.fi/problemset/task/1635)
|
|
|
|
* [Ordered](https://cses.fi/problemset/task/1636)
|
2020-06-03 19:25:39 +00:00
|
|
|
* [Minimum Coins](https://cses.fi/problemset/task/1634)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Paths on a Grid
|
|
|
|
* [Count Paths](https://atcoder.jp/contests/dp/tasks/dp_h)
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Palindromic Paths](http://www.usaco.org/index.php?page=viewproblem2&cpid=553)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Edit Distance
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Standard](https://www.hackerrank.com/contests/cse-830-homework-3/challenges/edit-distance)
|
|
|
|
* [Landscaping (Silver)](http://www.usaco.org/index.php?page=viewproblem2&cpid=126)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Longest Common Subsequence
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Standard](https://leetcode.com/problems/longest-common-subsequence/)
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Tree DP
|
|
|
|
* Tutorials:
|
2020-06-03 19:23:34 +00:00
|
|
|
* [DP on Trees (Codeforces)](https://codeforces.com/blog/entry/20935)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Problems
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Subtree](https://atcoder.jp/contests/dp/tasks/dp_v)
|
|
|
|
* [Independent Set](https://atcoder.jp/contests/dp/tasks/dp_p)
|
|
|
|
* [Barn Painting](http://www.usaco.org/index.php?page=viewproblem2&cpid=766)
|
|
|
|
* [Delegation](http://usaco.org/index.php?page=viewproblem2&cpid=1019)
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Bitmask DP
|
|
|
|
* Tutorials:
|
|
|
|
* CPH Chapter 10
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Dynamic Programming Over Subsets (Codeforces)](https://codeforces.com/blog/entry/337)
|
|
|
|
* [Dynamic Programming and Bit Masking (HackerEarth)](https://www.hackerearth.com/practice/algorithms/dynamic-programming/bit-masking/tutorial/)
|
2020-06-03 19:14:28 +00:00
|
|
|
* Problems:
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Moovie Moving](http://www.usaco.org/index.php?page=viewproblem2&cpid=515)
|
|
|
|
* [Matching](https://atcoder.jp/contests/dp/tasks/dp_o)
|
|
|
|
* [Square Subsets](https://codeforces.com/contest/895/problem/C)
|
|
|
|
* [Guards in the Storehouse](https://codeforces.com/problemset/problem/845/F)
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Practice Problems
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Atcoder DP Contest (Extremely Good)](https://atcoder.jp/contests/dp/tasks)
|
|
|
|
* [CSES DP Section](https://cses.fi/problemset/list/)
|
2020-06-03 19:14:28 +00:00
|
|
|
* USACO (Not Ordered By Difficulty)
|
2020-06-03 19:23:34 +00:00
|
|
|
* [Delegation](http://www.usaco.org/index.php?page=viewproblem2&cpid=1019)
|
|
|
|
* [Time is Mooney](http://www.usaco.org/index.php?page=viewproblem2&cpid=993)
|
|
|
|
* [Mortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971)
|
|
|
|
* [Snakes](http://www.usaco.org/index.php?page=viewproblem2&cpid=945)
|
|
|
|
* [Painting the Barn](http://usaco.org/index.php?page=viewproblem2&cpid=923)
|
|
|
|
* [Cow Poetry (Fast Exponentiation)](http://usaco.org/index.php?page=viewproblem2&cpid=897)
|
|
|
|
* [Teamwork](http://usaco.org/index.php?page=viewproblem2&cpid=863)
|
|
|
|
* [Talent Show](http://www.usaco.org/index.php?page=viewproblem2&cpid=839)
|
|
|
|
* [Taming the Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=815)
|
|
|
|
* [Stamp Painting](http://www.usaco.org/index.php?page=viewproblem2&cpid=791)
|
|
|
|
* [Why Did The Cow Cross the Road I](http://www.usaco.org/index.php?page=viewproblem2&cpid=717)
|
|
|
|
* [Why Did The Cow Cross the Road II](http://www.usaco.org/index.php?page=viewproblem2&cpid=718)
|
|
|
|
* [Hoof Paper Scissors](http://www.usaco.org/index.php?page=viewproblem2&cpid=694)
|
|
|
|
* [Cow Checklist](http://www.usaco.org/index.php?page=viewproblem2&cpid=670)
|
|
|
|
* [Circular Barn Revisited](http://www.usaco.org/index.php?page=viewproblem2&cpid=622)
|
|
|
|
* [Radio Contact](http://www.usaco.org/index.php?page=viewproblem2&cpid=598)
|
|
|
|
* [248](http://www.usaco.org/index.php?page=viewproblem2&cpid=647)
|
|
|
|
* [Fruit Feast](http://www.usaco.org/index.php?page=viewproblem2&cpid=574)
|
|
|
|
* [Codeforces DP Problem List](http://codeforces.com/blog/entry/325)
|