Using c++ to implement below problem by using the A-Staralgorithm!
Given a grid with obstacles, we want to find the shortest pathfrom a starting position to an ending position. This time we’d liketo use the A-Star algorithm. In this grid, you can only move infour directions: up, down, left, right therefore the heuristic thatwe will use will be Manhattan distance.
You’ve been hitting the gym, but have been taking it a bit easierrecently. So you can
still climb over obstacles, but it takes you even longer. Moving toa grid location without an
obstacle takes 1 minute. Moving to a grid location with an obstacletakes 3 minutes.
• The first line contains an integer, n, the dimension of the nxngrid.
• The second line contains two space-separated integers, thestarting position in the
order row column.
• The third line contains two space-separated integers, the endingposition in the order
• The next n lines contain the space separated row. Each element iseither a O indicating
no obstacle or a X indicating an obstacle.
Sample Input 0
40 23 1X X O XX X O OX X X OX O O O
Sample Output 0
Sample Input 1
6 0 15 2O O O O O XX X O X O OO O X O O XX O O O O OO O X X X OX O O X O O
Sample Output 1
Sample Input 2
40 03 2O O O OX X O OO O X OX O O O
Sample Output 2
Sample Input 3
83 36 6O O O O O O O OO O O O O O O OO O O O O O O OO O O O O O O OO O O O O O O OO O O O O O O OO O O O O O O OO O O O O O O O
Sample Output 3
Answer to Using c++ to implement below problem by using the A-Star algorithm! Given a grid with obstacles, we want to find the sh…