306337: CF1182B. Plus from Picture
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Plus from Picture
题意翻译
给定一张大小为 $w \times h$、由 `*` 和 `.` 组成的地图,试求地图中是否**有且仅有**一个满足如下条件的 `+` 形图形: - 中心点为 `*` - 上下左右四个方向都有一个或多个连续的 `*` - 除以上各点之外,整张地图均为 `.`题目描述
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.输入输出格式
输入格式
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.
输出格式
If the given picture satisfies all conditions, print "YES". Otherwise, print "NO". You can output each letter in any case (upper or lower).
输入输出样例
输入样例 #1
5 6
......
..*...
.****.
..*...
..*...
输出样例 #1
YES
输入样例 #2
3 5
..*..
****.
.*...
输出样例 #2
NO
输入样例 #3
7 7
.......
...*...
..****.
...*...
...*...
.......
.*.....
输出样例 #3
NO
输入样例 #4
5 6
..**..
..**..
******
..**..
..**..
输出样例 #4
NO
输入样例 #5
3 7
.*...*.
***.***
.*...*.
输出样例 #5
NO
输入样例 #6
5 10
..........
..*.......
.*.******.
..*.......
..........
输出样例 #6
NO