QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 1024 MB Total points: 100

#15822. Quarantine Policy

الإحصائيات

2019 冠状病毒病(COVID-19)可以通过飞沫和密切接触在人与人之间传播。在相对拥挤或封闭的空间(如飞机或火车)中,这种传播尤其容易且迅速。如果有人感染了 COVID-19,那么坐在相邻座位的乘客很容易被感染。

为了防止病毒传播,我们可以采取预防措施,例如勤洗手,避免触摸眼睛、鼻子或嘴巴,以避免感染。此外,政府也为此实施了隔离和检疫等特殊措施。例如,当飞机上有人感染冠状病毒时,该人需要被隔离。此外,坐在感染者相邻座位的人也需要被检疫。具体来说,相邻座位有两种类型。一种是直接相邻,即座位位于病毒座位的前、后、左或右方。另一种是对角线相邻,即座位位于病毒座位的左前、右前、左后或右后方。在检疫政策中,直接相邻座位的人将被检疫 $d_1$ 天,对角线相邻座位的人将被检疫 $d_2$ 天。如果某个座位周围有多个感染者,检疫天数不会累加。

请编写一个程序,输出哪些座位上的乘客需要被检疫,以及检疫的天数。如果某个座位上的乘客需要被检疫的天数不同,则输出这些天数中的最大值。

输入格式

输入包含多个测试用例。第一行表示测试用例的数量 $t$。对于每个测试用例,第一行包含四个整数 $n, m, d_1, d_2$ ($0 < n, m \le 100$, $1 \le d_2 \le d_1 < 10$),分别表示飞机的行数、列数,以及直接相邻(即前、后、左、右)座位需检疫 $d_1$ 天,对角线相邻(即左前、右前、左后、右后)座位需检疫 $d_2$ 天。接下来的 $n$ 行包含 $m$ 个字符,表示飞机上的座位。

每个健康座位用字符 ‘.’ 表示,每个病毒座位用字符 ‘V’ 表示。

输出格式

对于每架飞机,首先单独打印一行:

Airplane #$z$:

其中 $z$ 表示飞机的编号(从 1 开始)。接下来的 $n$ 行将输入中每个 ‘.’ 字符替换为该座位对应的检疫天数。

数据范围

  • $1 \le t \le 1000$
  • $0 < n, m \le 100$
  • $1 \le d_2 \le d_1 < 10$

样例

输入 1

2
4 4 7 3
.V..
....
..V.
....
2 2 1 1
V.
..

输出 1

Airplane #1:
7V70
3773
07V7
0373
Airplane #2:
V1
11

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.