modify DP a bit

This commit is contained in:
Benjamin Qi 2020-06-10 20:25:30 -04:00
parent 551e7921c7
commit 9c08fe9016
2 changed files with 44 additions and 32 deletions

View file

@ -10,15 +10,15 @@ prerequisites:
- Silver - Prefix Sums
---
An introduction to dynamic programming concepts needed for USACO Gold.
**Dynamic Programming (DP)** is a very important concept which emerges in the Gold division and extends to the IOI.
<!-- END DESCRIPTION -->
**Dynamic programming** is a very important concept which emerges in the USACO gold division and extends to the IOI. Typically, one or two problems from every contest in the gold division uses some sort of Dynamic programming.
Typically, at least one problem from every gold contest division involves some sort of DP.
## Tutorial
The following tutorials serve as an introduction into the mindset of Dynamic programming.
The following tutorials serve as an introduction into the mindset of DP.
- CPH 7
- great introduction that covers most classical problems
@ -39,12 +39,10 @@ Practice makes perfect. Start by doing some classical problems (try at least one
* also very good!
* [Codeforces DP Problem List](http://codeforces.com/blog/entry/325)
## Coin Change / Knapsack
(description)
## Bounded and Unbounded Knapsack
* Classic
* [Unbounded](https://www.hackerrank.com/challenges/unbounded-knapsack/problem)
* [Unbounded Knapsack](https://www.hackerrank.com/challenges/unbounded-knapsack/problem)
* [Unordered Coin Change](https://cses.fi/problemset/task/1635)
* [Ordered Coin Change](https://cses.fi/problemset/task/1636)
* [Minimum Coins](https://cses.fi/problemset/task/1634)
@ -52,9 +50,16 @@ Practice makes perfect. Start by doing some classical problems (try at least one
* [Large Capacity + Small Values](https://atcoder.jp/contests/dp/tasks/dp_e)
* Reconsider the state.
* USACO Gold
* [Talent Show](http://www.usaco.org/index.php?page=viewproblem2&cpid=839)
* [Fruit Feast](http://www.usaco.org/index.php?page=viewproblem2&cpid=574)
* straightforward
* [Talent Show](http://www.usaco.org/index.php?page=viewproblem2&cpid=839)
* binary search + knapsack on weight
* [Cow Poetry](http://usaco.org/index.php?page=viewproblem2&cpid=897)
* First consider the case where there are only two lines with the same class.
* Requires fast modular exponentiation for full credit.
* CF
* [Round Subset](http://codeforces.com/contest/837/problem/D) [](59)
* [Fire](http://codeforces.com/contest/864/problem/E) [](59)
## Paths on Grid (& Related)
@ -75,10 +80,16 @@ Practice makes perfect. Start by doing some classical problems (try at least one
* [Old Silver - Landscaping](http://www.usaco.org/index.php?page=viewproblem2&cpid=126)
* Although the problem looks different, this is actually a direct application of edit distance.
* [Old Gold - Palindromic Paths](http://www.usaco.org/index.php?page=viewproblem2&cpid=553)
* Consider the answer. What are some properties of it?
* What are some properties of the answer?
* Other
* [TC Interleaving Parentheses](https://community.topcoder.com/stat?c=problem_statement&pm=14635&rd=16933)
* [K-Ordered LCS](https://www.hackerearth.com/problem/algorithm/mancunian-and-k-ordered-lcs-e6a4b8c6/)
* [CSA Wrong Brackets](https://csacademy.com/contest/round-51/task/wrong-brackets/) [](69)
## Longest Increasing Subsequence
(add?)
* [LIS in Quadratic Time](https://leetcode.com/problems/longest-increasing-subsequence/)
* Try to improve to $O(N\log N)$.
* [Sort It Out (USACO Platinum)](http://www.usaco.org/index.php?page=viewproblem2&cpid=865)
@ -86,23 +97,22 @@ Practice makes perfect. Start by doing some classical problems (try at least one
## Additional USACO Problems
* Fairly Straightforward
* [Hoof Paper Scissors](http://www.usaco.org/index.php?page=viewproblem2&cpid=694)
* `dp[first i games][# changes][last gesture ] -> max games won`
* [Time is Mooney](http://www.usaco.org/index.php?page=viewproblem2&cpid=993)
* `dp[time][city] -> money`
* [Teamwork](http://usaco.org/index.php?page=viewproblem2&cpid=863)
* $O(NK^2)\to O(NK)$
* Trickier
* [Mortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971)
* Use Floyd-Warshall, Prefix Sums
* `dp[first i letters form valid combo][last letter] -> time`
* [Snakes](http://www.usaco.org/index.php?page=viewproblem2&cpid=945)
* `dp[first m groups][k changes] -> total sum of net sizes`
* [Taming the Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=815)
* `dp[consider first i entries only][last breakout in first i occurs at j][k breakouts among first i entries] -> # changes`
* [Stamp Painting](http://www.usaco.org/index.php?page=viewproblem2&cpid=791)
* must be $K$ consecutive with same color
* $O(NK)\to O(N)$
* [Circular Barn Revisited](http://www.usaco.org/index.php?page=viewproblem2&cpid=622)
* can brute force make your DP easier? (yes)
* [Hoof Paper Scissors](http://www.usaco.org/index.php?page=viewproblem2&cpid=694)
* `dp[first i games][# changes][last gesture ] -> max games won`
* [Time is Mooney](http://www.usaco.org/index.php?page=viewproblem2&cpid=993)
* `dp[time][city] -> money`
* [Teamwork](http://usaco.org/index.php?page=viewproblem2&cpid=863)
* $O(NK^2)\to O(NK)$
* [Snakes](http://www.usaco.org/index.php?page=viewproblem2&cpid=945)
* `dp[first m groups][k changes] -> total sum of net sizes`
* $O(N^4)\to O(N^3)$
* [Circular Barn Revisited](http://www.usaco.org/index.php?page=viewproblem2&cpid=622)
* can brute force make your DP easier? (yes)
* [Stamp Painting](http://www.usaco.org/index.php?page=viewproblem2&cpid=791)
* must be $K$ consecutive with same color
* $O(NK)\to O(N)$
* [Taming the Herd](http://www.usaco.org/index.php?page=viewproblem2&cpid=815)
* `dp[consider first i entries only][last breakout in first i occurs at j][k breakouts among first i entries] -> # changes`
* [Mortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971)
* Use Floyd-Warshall, Prefix Sums
* `dp[first i letters form valid combo][last letter] -> time`

View file

@ -23,6 +23,8 @@ Note: Has not appeared on recent USACO.
## Problems
* [Old Gold - 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)
* [AC Matching](https://atcoder.jp/contests/dp/tasks/dp_o)
* [CF Square Subsets](https://codeforces.com/contest/895/problem/C)
* [CF Guards in the Storehouse](https://codeforces.com/problemset/problem/845/F)
* [Kattis Cat & Mice](https://open.kattis.com/problems/catandmice) [](66)
* plus a bit of geometry