Need help with implementation

Revision en1, by Pieterson, 2025-06-01 12:09:48

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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Pieterson 2025-06-01 12:09:48 516 Initial revision (published)