We give you a painting of a snake. The lowercase letters ’x’ indicate parts of the snake, and the characters ’.’ represent empty spaces. The snake consists of a sequence of horizontal and vertical adjacent segments formed by letters ’x’. Successive fragments in the snake have a ’x’ in common, that belongs to the two fragments. There is not any ’x’ letter of different fragments of the word that is vertical or horizontal adjacent. For instance, the following snake has 6 fragments.
xxxxx...
....xxxx
.x.....x
.xxxxxxx
Given the draw of a snake, determine the length of its longest segment.
The input contains various paintings of snake. Each painting of snake consists of two integer numbers followed by a table of letters ’x’ and ’.’. The integer numbers specify the number of rows and columns of the painting of the snake. Each painting contains only a snake.
For each painting, your program must print a line with the corresponding result.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T11:29:48.178Z
© Jutge.org, 2006–2026.
https://jutge.org