Can someone please explain elaborately distributing dp. I found it in the editorial of atcoder problem Leaping Tak. Given below is the editorial link : https://atcoder.jp/contests/abc179/editorial/133
Thanks in advance :)
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Can someone please explain elaborately distributing dp. I found it in the editorial of atcoder problem Leaping Tak. Given below is the editorial link : https://atcoder.jp/contests/abc179/editorial/133
Thanks in advance :)
Название |
---|
could anyone provide all the atcoder contests with editorials
Distributing DP means that you take information about the current state, and pass it to future states.
Receiving DP means that you take information from previous states.
For example, if you're implementing a DP solution for finding the Fibonacci numbers, you could do either one:
thanks a lot mate for giving the reply and ur time besides some people waste time downvoting others .
If I understand correctly, does this mean that distributing DP couldn't be used in top down DP?
Distributing dp is also often referred to as push dp, and receiving dp is also called pull dp.
To briefly go over the differences between them, let's consider this problem.
In both methods, our definition of dp is the same, $$$ dp[x] = \text{minimum number of coins required to make value x} $$$
For push dp, you push results from currently available results.
so, if you consider adding coin with value $$$ c $$$ to your knapsack, and considering you already have the optimal value for some $$$ x $$$ in $$$ dp[x] $$$
then, from using $$$ dp[x] $$$ coins to make value $$$ x $$$, you can transition to, using $$$ dp[x]+1 $$$ coins to make value $$$ x+c $$$,
more programatically, we update $$$ dp[x+c] = min( dp[x+c], dp[x] + 1 ) $$$.
Notice how we "pushed" from an already computed value $$$ dp[x] $$$ to $$$ dp[x+c] $$$.
For pull dp, you pull results for the current state, from previously computed results.
you want to consider computing $$$ dp[x] $$$, let's say the last coin used to get to the current state was of value $$$ c $$$, then your update looks like, $$$ dp[x] = min( dp[x], dp[x-c] + 1 ); $$$
Here, you pull the results from already computed value of $$$ dp[x-c] $$$.
Additional Note: If you think about these methods, you realise the importance about order of processing. If the dp for your current state is not optimally calculated, and you push from there, and later optimally compute the dp for the state, then you can see that you would probably not get the optimal overall result. Thus, it leads you to the idea of a topological ordering of states, according to dependence on other states' results.