USACO 2020 December Contest, Platinum Problem 2. Spaceship

Правка en6, от gmyu.michael, 2020-12-28 23:38:47

[ again, this is for my personal usage. USACO solution is a little bit too difficult to understand, at least for me. The explanation below is easier to understand. ]

problem statement: http://usaco.org/index.php?page=viewproblem2&cpid=1069

dp(a,b,c) : number of ways from a -> b, the highest button used is upto c

  • first, after we press the button, we can stay at b, so dp(a,b,c) += dp(a,b,c-1)

  • or we go a -> r -> b with max button of c. In this case,

    between a->r, we find a point x with max button c-1. Then from x -> r the worse you can do is press button c

    between r -> b, since c-1 is reset and available, the worse we can do is press c-1 to a point y, then y->b use max button of c-1

then define

dp1(a,r,c-1) is sum over all x, where x->r, dp(a,x,c-1)

dp2(r,b,c-1) is sum over all y, where y->r, dp(y,b,c-1)
  • then dp(a,b,c) += sum over r, dp1 * dp2

Then we put constrain on (bs,s) and (bt,t)

use dp[2][2](a,b,c), 0/1 is whether s/t constrain is used or not

Then we put constrain on (bs,s) and (bt,t)

use dp[2][2](a,b,c), 0/1 is whether s/t constrain is used or not

  • doing the same, a -> b is sum over r of a -> r -> b

  • but a->r is pinned at the start, and r->b is pinned at the end

Code is here
Теги usaco

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en8 Английский gmyu.michael 2020-12-28 23:40:53 0 (published)
en7 Английский gmyu.michael 2020-12-28 23:39:58 109
en6 Английский gmyu.michael 2020-12-28 23:38:47 47 (saved to drafts)
en5 Английский gmyu.michael 2020-12-28 23:27:13 16
en4 Английский gmyu.michael 2020-12-28 04:34:03 4
en3 Английский gmyu.michael 2020-12-28 04:33:28 42 (published)
en2 Английский gmyu.michael 2020-12-28 04:11:19 10
en1 Английский gmyu.michael 2020-12-28 04:10:37 6591 Initial revision (saved to drafts)