PivotOJ

Pahuljice

시간 제한: 1000ms메모리 제한: 1024MB출처: COCI 2023-2024BOJ 30939

문제

Lana likes to draw specific snowflakes. A snowflake of size xx is defined as follows:

  • The center of the snowflake is the character '+'.
  • Above and below the character '+' there is a sequence of xx characters '|'.
  • To the left and right of the character '+' there is a sequence of xx characters '-'.
  • On the diagonal from the upper left corner to the center and from the center to the lower right corner of the snowflake there is a sequence of xx characters '\'.
  • On the diagonal from the upper right corner to the center and from the center to the lower left corner of the snowflake there is a sequence of xx characters '/'.

Sometimes Lana connects several snowflakes, but even then the size of each snowflake is determined separately, regardless of whether the snowflakes share some characters.

\|/
-+-
/|\
\.|./..
.\|/...
--+--..
./|\...
/.|.\|/
....-+-
..../|\
\.|./.
.\|/..
--+---
./|\..
/...\.

On the left is an example of a snowflake of size 11.

In the middle is an example of connected snowflakes, the left one of size 22 and the right one of size 11.

On the right is an example of a snowflake of size 11. It is missing one character '|' to be of size 22.

Lana is currently drawing snowflakes on a piece of paper of size n×mn \times m. However, she got a bit confused and did not draw all the snowflakes completely in accordance with her usual snowflake shapes. Namely, some snowflakes are missing some characters, so their size is equal to the smallest length of the corresponding character sequence from the center in one of the eight directions. Moreover, she drew some characters that are not part of any snowflake.

Can you help Lana determine the size of the largest snowflake in the drawing?

입력

The first line contains two integers nn and mm (1 ≤ n, m ≤ 50), the size of the drawing.

In each of the following nn lines there are mm characters describing the drawing.

The characters that can appear in the drawing are '+', '-', '\', '|', '/' and '.'. The ASCII values of these characters are 43, 45, 92, 124, 47 and 46 respectively.

출력

In the first and only line you should output the size of the largest snowflake in the drawing.

힌트

Clarification of the first example:

Only one snowflake is drawn.

In the directions up-left, up and up-right from the center of the snowflake there are sequences of length 11.

In the directions right and down-right from the center of the snowflake there are sequences of length 22.

In the directions left, down-left and down from the center of the snowflake there are sequences of length 33.

Therefore, the size of the snowflake is 11.

Clarification of the second example:

Two connected snowflakes are drawn, the left one of size 22 and the right one of size 11.

예제

예제 1

입력
5 6
\.\|/.
---+--
/./|\.
./.|.\
/..|..
출력
1

예제 2

입력
7 7
\.|./..
.\|/...
--+--..
./|\...
/.|.\|/
....-+-
..../|\
출력
2

예제 3

입력
7 7
\|/|\|/
-+-|-+-
/|\|/|\
---+---
\|/|\|/
-+-|-+-
/|\|/|\
출력
1
코드를 제출하려면 로그인하세요.