Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started