P9908 [COCI 2023/2024 #2] Pahuljice

Description

Lana likes drawing snowflakes. A snowflake of size $x$ is defined as follows. + The center of the snowflake is a $\texttt{'+'}$. + There are $x$ $\texttt{'|'}$ characters above and $x$ $\texttt{'|'}$ characters below the $\texttt{'+'}$. + There are $x$ $\texttt{'-'}$ characters to the left and $x$ $\texttt{'-'}$ characters to the right of the $\texttt{'+'}$. + There are $x$ $\texttt{'\textbackslash'}$ characters to the upper-left and $x$ $\texttt{'\textbackslash'}$ characters to the lower-right of the $\texttt{'+'}$. + There are $x$ $\texttt{'/'}$ characters to the lower-left and $x$ $\texttt{'/'}$ characters to the upper-right of the $\texttt{'+'}$. Snowflakes may overlap. Below are some examples of snowflakes. ![](https://cdn.luogu.com.cn/upload/image_hosting/2s81nyxm.png) The three pictures contain, respectively: one snowflake of size $1$; two overlapping snowflakes of sizes $2$ and $1$; and one snowflake of size $1$ (because a size $2$ snowflake is incomplete). Given an $n \times m$ character matrix, find the size of the largest snowflake in it.

Input Format

The first line contains two integers $n, m$. The next $n$ lines each contain a string of length $m$, describing an $n \times m$ matrix. It is guaranteed to contain only $\texttt{'+'}, \texttt{'-'}, \texttt{'|'}, \texttt{'/'}, \texttt{'\textbackslash'}, \texttt{'.'}$.

Output Format

Output one integer: the size of the largest snowflake. If there is none, output $0$.

Explanation/Hint

### Constraints |$\text{Subtask}$|Score|Special property| |:-:|:-:|:-:| |$1$|$11$|The largest snowflake size is $1$, or there is no snowflake at all.| |$2$|$11$|There is at most one $\texttt{'+'}$ in the matrix.| |$3$|$28$|None.| For all testdata, $1 \le n, m \le 50$. Translated by ChatGPT 5