QOJ.ac

QOJ

Limite de temps : 10 s Limite de mémoire : 256 MB Points totaux : 100

#23841. 气象预报员

Statistiques

JOI 市呈南北方向 $H$ 千米、东西方向 $W$ 千米的长方形,被划分为 $H \times W$ 个 $1$ 千米见方的小区域。从北数第 $i$ 个、从西数第 $j$ 个小区域记作 $(i, j)$。

每个小区域的上空要么有云,要么没有云。所有的云每过 $1$ 分钟就会向东移动 $1$ 千米。因为今天天气非常好,不会有云从 JOI 市外移动到 JOI 市内。

现在已知每个小区域的上空是否有云。作为气象预报员,你需要预测对于每个小区域,从现在起多少分钟后第一次会有云来到该小区域的上空。

对于每个小区域,求从现在起多少分钟后第一次会有云来到该小区域的上空。

输入格式

输入由 $1 + H$ 行组成。

第一行写有以空格分隔的整数 $H, W$ ($1 \le H \le 100, 1 \le W \le 100$)。这表示 JOI 市被划分为 $H \times W$ 个 $1$ 千米见方的小区域。

接下来的 $H$ 行中的第 $i$ 行 ($1 \le i \le H$) 写有一个由 $W$ 个字符组成的字符串。这 $W$ 个字符中的第 $j$ 个字符 ($1 \le j \le W$) 表示小区域 $(i, j)$ 的上空现在是否有云。如果有云则写有字符 'c'(小写英文字母),如果没有云则写有字符 '.'(英文句号)。

输出格式

输出由 $H$ 行组成,每行由以空格分隔的 $W$ 个整数组成。输出的第 $i$ 行第 $j$ 个整数 ($1 \le i \le H, 1 \le j \le W$) 必须表示从现在起多少分钟后第一次会有云来到小区域 $(i, j)$ 的上空。但是,如果现在小区域 $(i, j)$ 的上空已经有云,则输出 $0$;如果无论过多少分钟都不会有云来到小区域 $(i, j)$ 的上空,则输出 $-1$。

输出的每一行的行首和行尾不要包含多余的空格。

样例

输入格式 1

3 4
c..c
..c.
....

输出格式 1

0 1 2 0
-1 -1 0 1
-1 -1 -1 -1

说明

在样例 1 中,JOI 市被划分为 $3 \times 4$ 个小区域。现在 JOI 市的云况如下所示。图的上方表示北方。

problem_23841_94a18190c50f717cd44d7f844d77a7f4.png

在此之后,每过 $1$ 分钟,云按如下方式移动。

problem_23841_3184075bd335b0698ed70b0ebfc5c0ec.png problem_23841_1fbf60b384fef9f69c3256331aae624b.png problem_23841_6a3f4ba29e62183a0d7dacc38ab6caee.png

输入格式 2

6 8
.c......
........
.ccc..c.
....c...
..c.cc..
....c...

输出格式 2

-1 0 1 2 3 4 5 6
-1 -1 -1 -1 -1 -1 -1 -1
-1 0 0 0 1 2 0 1
-1 -1 -1 -1 0 1 2 3
-1 -1 0 1 0 0 1 2
-1 -1 -1 -1 0 1 2 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.