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.