Snaky P57940


Statement
 

pdf   zip

html

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.

Input

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.

Output

For each painting, your program must print a line with the corresponding result.

Public test cases
  • Input

    3 9
    x.xxx.xxx
    x.x.x.x.x
    xxx.xxx.x
    

    Output

    3
    
  • Input

    4 6
    xxxx..
    ...x..
    ...x..
    ......
    

    Output

    4
    
  • Information
    Author
    Omer Giménez
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++