305364: CF1015E1. Stars Drawing (Easy Edition)

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Stars Drawing (Easy Edition)

题意翻译

定义一个星星是下面形状的图形: - 由 $*$ 组成 - 星星的大小就是它向四个方向延伸的 $*$ 个数,注意四个方向要取最短的,不允许出现大小为0的星星 空的格子是 '$.$'(不包含引号),下面是几种星星的例子: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1015E1/dbf078fd5a2d2cf23bed0e2a7fa98ea60f68c8e9.png) 不难发现,左图是大小为 $1$ 的星星,中间的星星大小为 $2$ ,而右侧的星星大小为 $3$ 。 现在给定一个 $n\times m$ ,由'.'和'\*'(不包含引号)构成的的矩阵,你的任务是使用任意数量和大小的星星,画出这个矩阵上'\*'的图案,星星之间可以相交或重合。但星星不能超出矩阵。 ### 输入格式 一个 $n\times m$ $(3\le n,m\le100)$的字符矩阵,详细见题面 ### 输出格式 若有的'\*'不可能归属于任何星星,输出 $-1$ 。否则先输出所有合法星星的个数,接下来输出所有合法星星的中心坐标和大小(见样例)

题目描述

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: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1015E1/dbf078fd5a2d2cf23bed0e2a7fa98ea60f68c8e9.png)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 \times 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 \cdot 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 \cdot m $ stars.

输入输出格式

输入格式


The first line of the input contains two integers $ n $ and $ m $ ( $ 3 \le n, m \le 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.

输出格式


If it is impossible to draw the given grid using stars only, print "-1". Otherwise in the first line print one integer $ k $ ( $ 0 \le k \le n \cdot m $ ) — the number of stars needed to draw the given grid. The next $ k $ lines should contain three integers each — $ x_j $ , $ y_j $ and $ s_j $ , where $ x_j $ is the row index of the central star character, $ y_j $ is the column index of the central star character and $ s_j $ is the size of the star. Each star should be completely inside the grid.

输入输出样例

输入样例 #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 ``` <pre class="verbatim">2<br></br>3 4 1<br></br>3 5 2<br></br> ``` is also correct.

Input

题意翻译

定义一个星星是下面形状的图形: - 由 $*$ 组成 - 星星的大小就是它向四个方向延伸的 $*$ 个数,注意四个方向要取最短的,不允许出现大小为0的星星 空的格子是 '$.$'(不包含引号),下面是几种星星的例子: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1015E1/dbf078fd5a2d2cf23bed0e2a7fa98ea60f68c8e9.png) 不难发现,左图是大小为 $1$ 的星星,中间的星星大小为 $2$ ,而右侧的星星大小为 $3$ 。 现在给定一个 $n\times m$ ,由'.'和'\*'(不包含引号)构成的的矩阵,你的任务是使用任意数量和大小的星星,画出这个矩阵上'\*'的图案,星星之间可以相交或重合。但星星不能超出矩阵。 ### 输入格式 一个 $n\times m$ $(3\le n,m\le100)$的字符矩阵,详细见题面 ### 输出格式 若有的'\*'不可能归属于任何星星,输出 $-1$ 。否则先输出所有合法星星的个数,接下来输出所有合法星星的中心坐标和大小(见样例)

加入题单

算法标签: