P30037 [洛谷] [COCI 2023/2024 #2] Pahuljice
普及
题目描述

Problem Description

Lana loves drawing snowflakes. A snowflake of size $x$ is defined as follows:

  • The center of the snowflake is a $\texttt{'+'}$.
  • Above and below the $\texttt{'+'}$, there are $x$ $\texttt{'|'}$ characters.
  • To the left and right of the $\texttt{'+'}$, there are $x$ $\texttt{'-'}$ characters.
  • To the top-left and bottom-right of the $\texttt{'+'}$, there are $x$ $\texttt{'\textbackslash'}$ characters.
  • To the bottom-left and top-right of the $\texttt{'+'}$, there are $x$ $\texttt{'/'}$ characters.

Snowflakes can overlap. Below are examples of snowflakes:

The three images show a snowflake of size $1$, two overlapping snowflakes of sizes $2$ and $1$, and a snowflake of size $1$ (incomplete as part of a snowflake of size $2$).

Given a character matrix of size $n \times m$, find the size of the largest snowflake within it.

Input Format

The first line contains two integers $n$ and $m$.

The next $n$ lines each contain a string of length $m$, representing an $n \times m$ matrix. The matrix is guaranteed to only contain the characters $\texttt{'+'}$, $\texttt{'-'}$, $\texttt{'|'}$, $\texttt{'/'}$, $\texttt{'\textbackslash'}$, and $\texttt{'.'}$.

Output Format

Output a single integer representing the size of the largest snowflake. If there are none, output $0$.

Sample Input and Output

Sample Input #1

5 6
\.\|/.
---+--
/./|\.
./.|.\
/..|..

Sample Output #1

1

Sample Input #2

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

Sample Output #2

2

Sample Input #3

7 7
\|/|\|/
-+-|-+-
/|\|/|\
---+---
\|/|\|/
-+-|-+-
/|\|/|\

Sample Output #3

1

Notes

Data Range

Subtask Score Special Conditions
1 11 The largest snowflake size is $1$, or there are no snowflakes
2 11 There is at most one $\texttt{'+'}$ in the matrix
3 28 None

For all data, $1 \le n, m \le 50$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 6 \.\|/. ---+-- /./|\. ./.|.\ /..|..
样例输出
1