Answer to Question #53893 in C for Biswambhar Pal
Given a square maze (A) of dimension N, every entry (Aij) in the maze is either an open cell 'O' or a wall 'X'. A rat can travel to its adjacent locations (left, right, top and bottom), but to reach a cell, it must be open. Given the locations of R rats, can you find out whether all the rats can reach others or not.
Input will consist of three parts, viz.
1. Size of the maze (N)
2. The maze itself (A = N * N)
3. Number of rats (R)
4. Location of R rats (Xi, Yi)
(Xi,Yi) will represents the location of the i-th rat.
Locations are 1-index based.
Print "Yes" if the rats can reach each other, else print "No"
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!