MirrorMaze Problem Description In the mysterious island named Reflectia, there's a grid…
- User
MirrorMaze
Problem Description
In the mysterious island named Reflectia, there's a grid made up of M rows and N columns. Some cells in this grid are empty, while others hold mirrors which are placed diagonally to the cells. These mirrors are the reason why the island is called Reflectia - they bounce light beams in the opposite direction when the light hits them. The mirrors are placed in two ways viz., slanted forward (/) or slanted backwards ().
Rohit, a curious young explorer, decided to explore the Matrix with a flashlight in his hand as the island is very dark and is rumored to be haunted. Once he entered, he aimed to find out the maximum number of cells the light could travel to, making a closed loop, within the grid when it is bounced on one of the mirrors in the grid. As it was too dark, he noted the structure of the grid and came out.
Given the structure of the grid that Rohit noted, find out what’s the maximum number of cells the light could travel to, when it is bounced on one of the mirrors in the grid.
Constraints
3 ≤ M , N ≤ 50 3≤M,N≤50 Input
First line contains two integers separated by space, representing M and N. Next M lines contain N space-separated characters viz. ('.', '/', '') representing the grid structure. Output
Single integer representing the maximum number of cells that can be covered in the loop formed by the reflected light beam. Time Limit (secs) 1
ExamplesExample 1
Input
arduino 5 5
//00
000/0
0\00/
/\0/
000\ Output10
Example 2Input
6 6
0 0 0 0 /
0 / 0 / 0 0
0 \ 0 \ 0
0 / 1 \ 0
0 0 / 0
Output0 give c++ coide split in two functions and the most optimum
- Assistant
- User
the ouput is coming wrong redress it anfd give cpoorrect code
- Assistant