CF1015E1.Stars Drawing (Easy Edition)
普及+/提高
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length 0 are not allowed).
Let's consider empty cells are denoted by '.', then the following figures are stars:
The leftmost figure is a star of size 1, the middle figure is a star of size 2 and the rightmost figure is a star of size 3.
You are given a rectangular grid of size n×m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 1 to n, columns are numbered from 1 to m. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed n⋅m. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.
In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most n⋅m stars.
星形图案是一种如下所示的图形:中心为一个星号字符 *,并向左、右、上、下四个方向延伸出长度相等的四条射线。星形的大小即为其射线的长度。星形的大小必须为正整数(即不允许射线长度为 0)。
我们用字符 . 表示空白单元格,则以下图形均为星形:

最左侧图形是一个大小为 1 的星形,中间图形是一个大小为 2 的星形,最右侧图形是一个大小为 3 的星形。
给定一个仅由星号 * 和点号 . 构成的 n×m 矩形网格。行编号从 1 到 n,列编号从 1 到 m。你的任务是使用任意数量的星形来绘制该网格,或者判断这是不可能的。星形之间可以相交、重叠,甚至完全重合。输出中星形的数量不得超过 n⋅m。每个星形必须完全位于网格内部。你可以使用任意大小(包括相同大小)的星形。
本题不要求最小化星形数量,只需找出一种方案,用至多 n⋅m 个星形绘制出给定网格即可。
输入格式
The first line of the input contains two integers n and m (3≤n,m≤100) — the sizes of the given grid.
The next n lines contains m characters each, the i-th line describes the i-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.
输入的第一行包含两个整数 n 和 m(3≤n,m≤100)——表示给定网格的尺寸。
接下来的 n 行,每行包含 m 个字符;其中第 i 行描述网格的第 i 行。保证网格中仅包含字符 '*' 和 '.'。
输出格式
If it is impossible to draw the given grid using stars only, print "-1".
Otherwise in the first line print one integer k (0≤k≤n⋅m) — the number of stars needed to draw the given grid. The next k lines should contain three integers each — xj, yj and sj, where xj is the row index of the central star character, yj is the column index of the central star character and sj is the size of the star. Each star should be completely inside the grid.
如果仅使用星号(*)无法绘制给定的网格,则输出 -1。
否则,第一行输出一个整数 k(0≤k≤n⋅m),表示绘制该网格所需的星号图案个数。接下来的 k 行每行应包含三个整数:xj、yj 和 sj,其中 xj 是星号图案中心字符所在的行索引,yj 是星号图案中心字符所在的列索引,sj 是该星号图案的尺寸。每个星号图案必须完全位于网格内部。
输入输出样例
输入#1
6 8 ....*... ...**... ..*****. ...**... ....*... ........
输出#1
3 3 4 1 3 5 2 3 5 1
输入#2
5 5 .*... ****. .**** ..**. .....
输出#2
3 2 2 1 3 3 1 3 4 1
输入#3
5 5 .*... ***.. .*... .*... .....
输出#3
-1
输入#4
3 3 *.* .*. *.*
输出#4
-1
说明/提示
In the first example the output
2
3 4 1
3 5 2
is also correct.
在第一个例子中,以下输出
2
3 4 1
3 5 2
也是正确的。
输入解题思路,AI测评打分。不知道怎么写?