3937 - Flooded Area

Created by Marcelo Fornet Fornés
Added by cjoa (2017-10-05)
Limits
Total Time: 10000 MS | Test Time: 1000 MS |Memory: 512 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

For the past few days, Mother Nature has not been kind to the country of Berland, where many areas are currently flooded due to heavy rain.

For simplicity, we can view Berland as a two dimensional grid of R x C cells (ie, R rows with C cells on each row). Each cell can be dry ('*') or wet ('.').

As part of Berland's relief efforts, your task is to determine whether there exists exactly one single square area consisting entirely of dry cells in Berland.  In particular, this means that the square should not have any "holes".
En días recientes, la Madre Naturaleza no ha tratado bien al pais de Berland causando inundaciones en muchas áreas debido a las constantes lluvias.

Para simplicidad, podemos visualizar a Berland como una matriz bidimensional de R x C celdas (es decir, R filas con C celdas en cada fila. Cada celda puede estar seco ('*') o inundado ('.').

Como parte del cuerpo de rescates, tu tarea es determinar si existe en Berland exactamente un área que contenga solamente celdas secas y que tenga forma de cuadrado.  En particular, esto implica que el cuadrado no debe tener ningún "hueco".
;jsessionid=59119E905ED5EF6F4993BFBAD6D51B80
For the past few days, Mother Nature has not been kind to the country of Berland, where many areas are currently flooded due to heavy rain.

For simplicity, we can view Berland as a two dimensional grid of R x C cells (ie, R rows with C cells on each row). Each cell can be dry ('*') or wet ('.').

As part of Berland's relief efforts, your task is to determine whether there exists exactly one single square area consisting entirely of dry cells in Berland.  In particular, this means that the square should not have any "holes".

Input specification

The first line of input consists of integers R and C (1 ≤ R, C ≤ 50), denoting the number of rows and columns in the grid. The next R lines describe the grid. Each of these lines has exactly C characters, where '*' indicates a dry cell and '.' is a flooded cell.

La primera línea de entrada consiste en dos números enteros R y C(1 ≤ R, C ≤ 50), indicando la cantidad de filas y columnas en la matriz. Las siguientes R líneas describen la matriz. Cada una de esas líneas tiene exactamente C caracteres, donde '*' indica que es una celda seca y '.' es una celda inundada.

The first line of input consists of integers R and C (1 ≤ R, C ≤ 50), denoting the number of rows and columns in the grid. The next R lines describe the grid. Each of these lines has exactly C characters, where '*' indicates a dry cell and '.' is a flooded cell.

Output specification

Output the word "YES" if there is exactly one square dry area in Berland. Otherwise, output the word "NO".
Imprima la palabra "YES" si Berland contiene exactamente un área con forma de cuadrado y que solo consiste en celdas no inundadas. De lo contrario, imprime la palabra "NO".

The first line of input consists of integers R and C (1 ≤ R, C ≤ 50), denoting the number of rows and columns in the grid. The next R lines describe the grid. Each of these lines has exactly C characters, where '*' indicates a dry cell and '.' is a flooded cell.

Sample input

3 5
..**.
..**.
.....

Sample output

YES

Hint(s)

Other examples:

3 4
....
.*..
....
Answer: YES

3 3
***
***
***
Answer: YES

2 4
.***
.***
Answer: NO

3 3
***
*.*
***
Answer: NO

3 6
.**.**
.**.**
......
Answer: NO

In the last example, answer is NO because there are actually two dry squares in Berland.
Otros ejemplos:

3 4
....
.*..
....
Respuesta: YES

3 3
***
***
***
Respuesta: YES

2 4
.***
.***
Respuesta: NO

3 3
***
*.*
***
Respuesta: NO

3 6
.**.**
.**.**
......
Respuesta: NO

En el último ejemplo, la respuesta es NO porque existen dos cuadrados con celdas no inundadas, no uno.
Other examples:

3 4
....
.*..
....
Answer: YES

3 3
***
***
***
Answer: YES

2 4
.***
.***
Answer: NO

3 3
***
*.*
***
Answer: NO

3 6
.**.**
.**.**
......
Answer: NO

In the last example, answer is NO because there are actually two dry squares in Berland.