Question: Problem Description: An ancient treasure map has been discovered, consisting of a grid of N x M cells. Each cell of the map contains a
Problem Description:
An ancient treasure map has been discovered, consisting of a grid of N x M cells. Each cell of the map contains a number, representing the number of steps to move from that cell. A step can be made to any adjacent cell up down, left, right but not diagonally. The map includes several marked locations where the treasure might be hidden. To find the actual treasure, a seeker may start from anywhere on the map and follow the steps as indicated by the numbers in the cells.
However, there is a problem: the map is partially damaged, and some cells have become unreadable. Your task is to determine if it is still possible to reach a marked treasure location, and if so find the shortest path to any of the marked locations.
Input:
The first line contains two integers, N and M N M the dimensions of the map. The next N lines each contain M integers, representing the map grid. Each integer is between and inclusive. A indicates an unreadable cell. At least one cell will be marked with a special number greater than indicating a potential treasure location.
The topleft corner is always a valid starting cell nonzero
Please provide this solution in c
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
