A12752 | Plus from Picture
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
- 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.
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).
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
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted