CF1015E1.Stars Drawing (Easy Edition)

普及/提高-

通过率:0%

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 00 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 11 , the middle figure is a star of size 22 and the rightmost figure is a star of size 33 .You are given a rectangular grid of size n×mn \times m consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from 11 to nn , columns are numbered from 11 to mm . 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 nmn \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 nmn \cdot m stars.

输入格式

The first line of the input contains two integers nn and mm ( 3n,m1003 \le n, m \le 100 ) — the sizes of the given grid.

The next nn lines contains mm characters each, the ii -th line describes the ii -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 kk ( 0knm0 \le k \le n \cdot m ) — the number of stars needed to draw the given grid. The next kk lines should contain three integers each — xjx_j , yjy_j and sjs_j , where xjx_j is the row index of the central star character, yjy_j is the column index of the central star character and sjs_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.

首页