2020-06-04 01:42:57 +00:00
|
|
|
---
|
|
|
|
slug: /gold/dp
|
2020-06-04 05:39:49 +00:00
|
|
|
title: "Dynamic Programming"
|
2020-06-04 01:42:57 +00:00
|
|
|
author: Michael Cao
|
2020-06-04 05:39:49 +00:00
|
|
|
order: 1
|
2020-06-04 01:42:57 +00:00
|
|
|
---
|
|
|
|
|
2020-06-04 05:39:49 +00:00
|
|
|
<div class="syllabus-only">
|
|
|
|
Description: Todo
|
|
|
|
</div>
|
2020-06-04 02:09:42 +00:00
|
|
|
|
2020-06-04 05:39:49 +00:00
|
|
|
<!-- END DESCRIPTION -->
|
2020-06-03 14:17:07 +00:00
|
|
|
|
2020-06-03 19:14:28 +00:00
|
|
|
## Prerequisites
|
2020-06-04 02:09:42 +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
|
2020-06-03 21:42:26 +00:00
|
|
|
|
2020-06-04 21:42:30 +00:00
|
|
|
- CPH 7
|
|
|
|
- [HackerRank DP](https://www.hackerrank.com/topics/dynamic-programming)
|
|
|
|
- [Topcoder DP](https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/)
|
|
|
|
- [CPC.6](https://github.com/SuprDewd/T-414-AFLV/tree/master/06_dynamic_programming)
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Classical DP Problems
|
2020-06-03 21:42:26 +00:00
|
|
|
|
2020-06-03 19:14:28 +00:00
|
|
|
Tutorials for most problems (excluding USACO) can be found on Chapter 7 of CPH.
|
2020-06-03 21:42:26 +00:00
|
|
|
|
|
|
|
* Knapsack
|
|
|
|
* [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 (USACO Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=839)
|
|
|
|
* [Fruit Feast (USACO Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=574)
|
|
|
|
* Longest Increasing Subsequence
|
|
|
|
* [LIS in Quadratic Time](https://leetcode.com/problems/longest-increasing-subsequence/)
|
2020-06-04 02:12:00 +00:00
|
|
|
* Try to improve to $O(N\log N)$.
|
2020-06-03 21:42:26 +00:00
|
|
|
* [Sort It Out (USACO Platinum)](http://www.usaco.org/index.php?page=viewproblem2&cpid=865)
|
|
|
|
* Coin Change
|
|
|
|
* [Unordered](https://cses.fi/problemset/task/1635)
|
|
|
|
* [Ordered](https://cses.fi/problemset/task/1636)
|
|
|
|
* [Minimum Coins](https://cses.fi/problemset/task/1634)
|
|
|
|
* Paths on a Grid
|
|
|
|
* [Count Paths](https://atcoder.jp/contests/dp/tasks/dp_h)
|
|
|
|
* [Palindromic Paths (Old USACO Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=553)
|
|
|
|
* Edit Distance
|
|
|
|
* [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)
|
|
|
|
* Longest Common Subsequence
|
|
|
|
* [Standard](https://leetcode.com/problems/longest-common-subsequence/)
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Tree DP
|
2020-06-03 21:42:26 +00:00
|
|
|
|
|
|
|
* Tutorial
|
|
|
|
* [DP on Trees (Codeforces)](https://codeforces.com/blog/entry/20935)
|
|
|
|
* Problems
|
|
|
|
* [Subtree](https://atcoder.jp/contests/dp/tasks/dp_v)
|
|
|
|
* [Independent Set](https://atcoder.jp/contests/dp/tasks/dp_p)
|
|
|
|
* [Barn Painting (USACO Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=766)
|
|
|
|
* [Delegation (USACO Gold)](http://usaco.org/index.php?page=viewproblem2&cpid=1019)
|
2020-06-03 19:14:28 +00:00
|
|
|
|
|
|
|
## Bitmask DP
|
2020-06-03 21:42:26 +00:00
|
|
|
|
|
|
|
Note: Has not appeared on recent USACO.
|
|
|
|
|
|
|
|
* Tutorials:
|
|
|
|
* CPH Chapter 10
|
|
|
|
* [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/)
|
|
|
|
* Problems:
|
2020-06-04 02:09:42 +00:00
|
|
|
* [Moovie Moving (Old USACO Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=515)
|
2020-06-03 21:42:26 +00:00
|
|
|
* [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 21:42:26 +00:00
|
|
|
|
2020-06-04 21:42:30 +00:00
|
|
|
* **[Atcoder DP Contest (Extremely Good)](https://atcoder.jp/contests/dp/tasks)**
|
2020-06-03 21:42:26 +00:00
|
|
|
* [CSES DP Section](https://cses.fi/problemset/list/)
|
|
|
|
* [Codeforces DP Problem List](http://codeforces.com/blog/entry/325)
|
|
|
|
* USACO (Not Ordered By Difficulty)
|
|
|
|
* [Time is Mooney](http://www.usaco.org/index.php?page=viewproblem2&cpid=993)
|
|
|
|
* Graph
|
|
|
|
* [Mortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971)
|
|
|
|
* with Prefix Sums
|
|
|
|
* [Painting the Barn](http://usaco.org/index.php?page=viewproblem2&cpid=923)
|
|
|
|
* with 2D Prefix Sums
|
|
|
|
* [Snakes](http://www.usaco.org/index.php?page=viewproblem2&cpid=945)
|
|
|
|
* [Cow Poetry](http://usaco.org/index.php?page=viewproblem2&cpid=897)
|
2020-06-04 02:09:42 +00:00
|
|
|
* with fast exponentiation
|
2020-06-03 21:42:26 +00:00
|
|
|
* [Teamwork](http://usaco.org/index.php?page=viewproblem2&cpid=863)
|
|
|
|
* [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)
|