QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100

#3489. 浓缩咖啡币

Estadísticas

大型连锁咖啡店 Espresso Bucks 正在向 Gridland 国家扩张。由于你是 Gridland 文化和地理方面的专家,Espresso Bucks 聘请你来决定在哪里开设咖啡店以实现利润最大化。Gridland 由一个 $n \times m$ 的网格组成,其中一些单元格是陆地,另一些是水域。每个陆地单元格最多只能建造一家咖啡店。水域单元格上不能建造任何东西,但另一方面,水域中也没有人居住。在与 Espresso Bucks 的相关人员进行了多次长时间的会议后,你得出结论,咖啡店的选址必须满足以下两个约束条件:

  1. 每个陆地单元格必须在其自身位置或其相邻位置上有一家咖啡店。
  2. 任意两家咖啡店不能相邻。

如果两个单元格位于彼此的西、北、东或南侧,则称它们是相邻的。请找到任何满足这些约束条件的咖啡店布局。

图片由 Pixabay 的 talinamalu 提供

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 100$)。接下来的 $n$ 行,每行包含一个长度为 $m$ 的字符串,仅由字符 ‘.’(陆地)和 ‘#’(水域)组成。这是 Gridland 的地图。保证地图中至少包含一个陆地单元格。

输出格式

输出 Gridland 地图的副本,其中一些陆地单元格已被替换为字母 ‘E’,表示在该陆地单元格上开设了一家咖啡店。此布局应满足上述约束条件。如果存在多种解决方案,接受其中任何一种即可。

样例

输入格式 1

5 6
....#.
....#.
#.....
......
##...#

输出格式 1

E..E#.
..E.#E
#..E..
.E...E
##E.E#

输入格式 2

10 16
########.#....##
######......####
#####.....######
###.......######
##.......#######
##.........#####
##......########
##....##########
###.############
##...###########

输出格式 2

########E#.E.E##
######E...E.####
#####E.E.E######
###E..E.E.######
##E..E.E.#######
##.E..E..E.#####
##E..E.E########
##.E..##########
###.############
##E.E###########

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.