CF1182B.Plus from Picture
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have a given picture with size w×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.
你有一张尺寸为 w×h 的给定图片。请判断该图片是否恰好包含一个“+”形图案。“+”形图案定义如下:
- “+”形图案具有一个中心非空单元格;
- 从该中心出发,在四个方向(左、右、上、下)中的每一个方向上,都必须存在若干(至少一个)连续的非空单元格。换言之,每个方向上都必须延伸出一条射线;
- 所有其他单元格均为空。
请判断给定图片中是否恰好包含一个“+”形图案。
输入格式
The first line contains two integers h and w (1≤h, w≤500) — the height and width of the picture.
The i-th of the next h lines contains string si of length w consisting "." and "*" where "." denotes the empty space and "*" denotes the non-empty space.
第一行包含两个整数 h 和 w(1≤h,w≤500),分别表示图片的高度和宽度。
接下来的 h 行中,第 i 行包含一个长度为 w 的字符串 si,该字符串仅由字符 "." 和 "*" 组成,其中 "." 表示空白位置,"*" 表示非空白位置。
输出格式
If the given picture satisfies all conditions, print "YES". Otherwise, print "NO".
You can output each letter in any case (upper or lower).
如果给定的图片满足所有条件,则输出 “YES”。否则,输出 “NO”。
您可以以任意大小写(大写或小写)输出每个字母。
输入输出样例
输入#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.
在第一个例子中,给定的图片包含一个“+”。
在第二个例子中,两条竖直分支位于不同的列中。
在第三个例子中,形状外部存在一个点。
在第四个例子中,两条竖直分支的宽度为 2。
在第五个例子中,存在两个形状。
在第六个例子中,形状内部存在一处空白区域。
输入解题思路,AI测评打分。不知道怎么写?