Блог пользователя wronganswer.5

Автор wronganswer.5, история, 12 месяцев назад, По-английски

This question was asked was in an OA. I was not able to sovle it fully i.e my soln got partially accepted.

Code

I want to solve this problem via memorization as I am not so good at writing bottom-up approach directly.

I took 5 states-> X and Y coordinates of alice and bob and index of the corr(array of position of apples). How to optimize states?

Thanks in advance.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
12 месяцев назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

Firstly, observe that there are only $$$n+2$$$ locations/coordinates you care about: the $$$n$$$ apples and starting locations of Alice and Bob. So a naive dp state might look like $$$dp[Current\;apple][Alice\;location][Bob\;location]$$$. However this is $$$n^3$$$ and is likely too slow for given constraints.

Hint #1
Hint #2
Solution
»
12 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Which college are you from??