REtoAC2001's blog

By REtoAC2001, history, 3 years ago, In English

While writing a recursive solution to the problem https://codeforces.net/contest/1389/problem/B I didn't take count (which is the number of steps taken till now) into account in the dp states. But now that I think of it ,I wonder why doesn't the dp(recursion) depend on the no of steps left.
Here is the link to my submission :https://codeforces.net/contest/1389/submission/122378801. Here idx represents the present index we are currently in, check denotes whether the last move was left(1) or right(0) and mleft is count of moves to the left we have taken so far. Can anyone help me understand why is it independent on the no of steps taken/left.

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Have you seen the editorial at https://codeforces.net/blog/entry/80809? I haven't read over your code but from the editorial you can see that DP isn't even needed for this problem.