USACO 2020 December Contest, Platinum Problem 2. Spaceship

Revision en7, by gmyu.michael, 2020-12-28 23:39:58

[ 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. ] - BTW, if anybody knows how to make a blog private, please write the instruction in the comment section.

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
Tags usaco

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en8 English gmyu.michael 2020-12-28 23:40:53 0 (published)
en7 English gmyu.michael 2020-12-28 23:39:58 109
en6 English gmyu.michael 2020-12-28 23:38:47 47 (saved to drafts)
en5 English gmyu.michael 2020-12-28 23:27:13 16
en4 English gmyu.michael 2020-12-28 04:34:03 4
en3 English gmyu.michael 2020-12-28 04:33:28 42 (published)
en2 English gmyu.michael 2020-12-28 04:11:19 10
en1 English gmyu.michael 2020-12-28 04:10:37 6591 Initial revision (saved to drafts)