Question: please help me to solve this problem using graph theory in puthon . time limit per test: 2 secondso memory limit per test: 1024 megabytes

please help me to solve this problem using graph theory in puthon .
 please help me to solve this problem using graph theory in

time limit per test: 2 secondso memory limit per test: 1024 megabytes input: standard input output: standard output Yi and Han are two swans living on a lake. They are good friends and often play together. One day they woke up and found out that because of the snow last night, they were separate in two different areas by ice. The lake can be viewed as a rc grid. We will use " X " to represent a cell of ice. and "." a cell as water. At the beginning, Yi and Han are both at a cell of water. Every day, some ice cells " X " will melt. An ice cell " X " melts if and only if in the previcus day, at least one of its adjacent grids is water. Here "adjacent" means on the top, bottom, left and right, at most 4 of them. An example of the ice melting process is shown above. Yi and Han can both swim to any adjacent water cell from their current position, but they cannot swim to any ice cells. They both swim very fast so that they can arrive at any cell on the lake instantly as long as two cells are connected with water cells. Given the initial position of Yi and Han, and the current status of the lake, decide that at which day Yi and Han can meet again. Input The first line contains two integers r and c,1r,c1500. The following r lines each contains c characters, which describes the initial status of the lake. " "means a water cell. " X " means an ice cell, "L" means a swan. Output The output only contains one integer t, which means that after t days, Y and Han can meet

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!