Блог пользователя Pieterson

Автор Pieterson, история, 11 месяцев назад, По-английски

https://cses.fi/problemset/task/3359/ Note: I already searched for the answer in the dp editorial. I was not able to find it. This seems like a pretty straightforward dp problem. But I am getting TLE. Like if I want to reach a square (i,j) then dp[i][j]=min(dp[i-1][j],dp[i][j-1]), and then i push back grid[i][j]. But the problem is comparing the two strings dp[i-1][j],dp[i][j-1] takes longer time than comparing numbers, for example, in the minimum sum path problem. Please help.

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