Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pythone code E. Swans time limit per test: 2 seconds 0 memory limit per test: 1024 megabytes input: standard input output: standard output Yi and

image text in transcribed

pythone code

E. Swans time limit per test: 2 seconds 0 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 previous 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, Yi and Han can meet

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

Evaluate the impact of unions on nurses and physicians.

Answered: 1 week ago

Question

Describe the impact of strikes on patient care.

Answered: 1 week ago

Question

Evaluate long-term care insurance.

Answered: 1 week ago