CF152D.Frames
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One day Vasya got hold of a sheet of checkered paper n × m squares in size. Our Vasya adores geometrical figures, so he painted two rectangles on the paper. The rectangles' sides are parallel to the coordinates' axes, also the length of each side of each rectangle is no less than 3 squares and the sides are painted by the grid lines. The sides can also be part of the sheet of paper's edge. Then Vasya hatched all squares on the rectangles' frames.
Let's define a rectangle's frame as the set of squares inside the rectangle that share at least one side with its border.
A little later Vasya found a sheet of paper of exactly the same size and couldn't guess whether it is the same sheet of paper or a different one. So, he asked you to check whether the sheet of paper he had found contains two painted frames and nothing besides them.
Please note that the frames painted by Vasya can arbitrarily intersect, overlap or even completely coincide.
The coordinates on the sheet of paper are introduced in such a way that the X axis goes from top to bottom, the x coordinates of the squares' numbers take values from 1 to n and the Y axis goes from the left to the right and the y coordinates of the squares' numbers take values from 1 to m.
一天,瓦西娅得到了一张大小为 n×m 个方格的方格纸。我们的瓦西娅非常喜爱几何图形,因此他在纸上画了两个矩形。这两个矩形的边均与坐标轴平行,且每个矩形每条边的长度均不小于 3 个方格,其边均沿网格线绘制。矩形的边也可以恰好与纸张的边缘重合。随后,瓦西娅将这两个矩形“框”(frame)内的所有方格全部涂黑。
我们定义一个矩形的框(frame)为:该矩形内部所有至少有一条边与其边界相邻的方格所组成的集合。
不久之后,瓦西娅又找到了一张尺寸完全相同的方格纸,却无法判断这张纸是否就是原先那张,还是另一张不同的纸。因此,他请你帮忙检查:他找到的这张纸上是否恰好包含两个被涂黑的框,且除此之外再无其他被涂黑的方格。
请注意:瓦西娅所画的两个框可以任意相交、重叠,甚至完全重合。
纸上的坐标系定义如下:X 轴自上而下延伸,方格的 x 坐标取值范围为 1 到 n;Y 轴自左向右延伸,方格的 y 坐标取值范围为 1 到 m。
输入格式
The first input line contains two integers n and m (3 ≤ n, m ≤ 1000) — the sizes of the sheet of paper Vasya found. Next n lines, each consisting of m symbols "." (dot) and "#" (number sign), describe the found sheet of paper. The symbol "#" represents a hatched square and the symbol "." represents a non-hatched square.
第一行输入包含两个整数 n 和 m(3 ≤ n, m ≤ 1000)——表示瓦夏找到的纸张尺寸。接下来的 n 行,每行包含 m 个字符,字符为 .(英文句点)或 #(井号),用于描述这张纸。符号 # 表示一个带阴影的方格,符号 . 表示一个无阴影的方格。
输出格式
In the first line print the single word "YES" or "NO", meaning whether it is true that the found sheet of paper has two frames painted on it. If the answer is positive, then print in the second line 4 integers: the coordinates of the upper left and lower right corners of the first frame. In the third line print 4 integers: the coordinates of the upper left and the lower right corners of the second frame. If there are multiple answers, print any of them.
第一行输出单个单词“YES”或“NO”,表示所找到的纸张上是否恰好绘制了两个矩形框。
如果答案为肯定(即输出“YES”),则在第二行输出 4 个整数:第一个矩形框的左上角和右下角坐标。
第三行输出 4 个整数:第二个矩形框的左上角和右下角坐标。
若存在多个合法答案,输出任意一个即可。
输入输出样例
输入#1
4 5 ##### #.#.# ###.# #####
输出#1
YES 1 1 3 3 1 1 4 5
输入#2
5 6 ...### ...### #####. #...#. #####.
输出#2
NO
说明/提示
In the first sample there are two frames on the picture. The first one is:
###..
#.#..
###..
.....
The second one is:
#...#
#...#
In the second sample the painted figures are not frames. Note that the height and width of valid frames is no less than 3.
第一个样例中,图片上有两个框架。第一个框架是:
###..
#.#..
###..
.....
第二个框架是:
#...#
#...#
在第二个样例中,被涂色的图形不是框架。注意:有效框架的高度和宽度均不小于 3。
输入解题思路,AI测评打分。不知道怎么写?