I train for programming competitions, and I turn to complex problems that I could not answer in the past. One of them was the labyrinth king. Essentially, you are given an array of NxN numbers -50<x<50 , which are tokens. You should start at position 1.1 (I assume that 0.0 is in the index of the array) and end with N, N. You must pick up the tokens in the cells you are visiting, and you cannot step on a cell without a marker (represented by 0 ) If you are surrounded by 0, you lose. If there is no solution in the maze, you display "No solution." In addition, you print the maximum possible amount that you can get by adding the tokens that you receive.
I do not know how to solve this problem. I decided that you can write a labyrinth algorithm to solve it, but it takes time, and in programming contests you are given only two hours to solve several problems. I guess there is some kind of pattern that I am missing. Does anyone know how I should approach this?
In addition, it may help to mention that this problem is for high school students.
source share