QOJ.ac

QOJ

実行時間制限: 10 s メモリ制限: 256 MB 満点: 100

#23841. 氣象預報員

統計

JOI 市係一個南北方向 $H$ 公里、東西方向 $W$ 公里嘅長方形,分咗做 $H \times W$ 個 $1$ 公里乘 $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.