Editorial for DMOPC '14 Contest 4 P3 - Golden Lily
Submitting an official solution before solving the problem yourself is a bannable offence.
By Eduard Ionescu
The intended solution involved finding the minimum sum of the densities required to reach each tile (running DP on the grid). More specifically, move from left to right obtaining the sum by adding the value of the current tile to the minimum of the one on its left, right, or above. You will also have to run through each length twice as you can move to the left as well. To better understand the problem, it is recommended that you create a case where the cheapest path includes moving to the left.
Time Complexity:
Note: Some participants solved it using Dijkstra's Shortest Path Algorithm, as the grid could be represented as a weighted graph with non-negative edges. However, this is a suboptimal solution and only passes due to the lenient time limit.
Time Complexity: , using a binary heap
Comments