Codeforces Round 566 (Div. 2)
B
Plus from Picture
Codeforces
1300
原题
← AC →
翻译中…

You have a given picture with size $w \times h$. Determine if the given picture has a single "+" shape or not. A "+" shape is described below:

翻译中…
  • A "+" shape has one center nonempty cell.
  • There should be some (at least one) consecutive non-empty cells in each direction (left, right, up, down) from the center. In other words, there should be a ray in each direction.
  • All other cells are empty.
翻译中…

Find out if the given picture has single "+" shape.

翻译中…

Input

翻译中…

The first line contains two integers $h$ and $w$ ($1 \le h$, $w \le 500$) — the height and width of the picture.

翻译中…

The $i$-th of the next $h$ lines contains string $s_{i}$ of length $w$ consisting "." and "*" where "." denotes the empty space and "*" denotes the non-empty space.

翻译中…

Output

翻译中…

If the given picture satisfies all conditions, print "YES". Otherwise, print "NO".

翻译中…

You can output each letter in any case (upper or lower).

翻译中…

Note

翻译中…

In the first example, the given picture contains one "+".

翻译中…

In the second example, two vertical branches are located in a different column.

翻译中…

In the third example, there is a dot outside of the shape.

翻译中…

In the fourth example, the width of the two vertical branches is $2$.

翻译中…

In the fifth example, there are two shapes.

翻译中…

In the sixth example, there is an empty space inside of the shape.

翻译中…

样例

Input #1
5 6
......
..*...
.****.
..*...
..*...
Output #1
YES
InputCopy OutputCopy
Input #2
3 5
..*..
****.
.*...
Output #2
NO
InputCopy OutputCopy
Input #3
7 7
.......
...*...
..****.
...*...
...*...
.......
.*.....
Output #3
NO
InputCopy OutputCopy
Input #4
5 6
..**..
..**..
******
..**..
..**..
Output #4
NO
InputCopy OutputCopy
Input #5
3 7
.*...*.
***.***
.*...*.
Output #5
NO
InputCopy OutputCopy
Input #6
5 10
..........
..*.......
.*.******.
..*.......
..........
Output #6
NO
InputCopy OutputCopy
题目信息
题号
1182B
时间限制
1 s
内存限制
256 MB
标签
DFS 及类似
模拟
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。