QOJ.ac

QOJ

Time Limit: 4.0 s Memory Limit: 1024 MB Total points: 100
Statistics

Bajtocja 是一块由 $H \times W$ 个单元格组成的矩形土地,排列为 $H$ 行 $W$ 列。每个单元格的边界都是一条交通流量很小的当地道路。每个单元格要么是空的,要么住着一位居民。居民们喜欢安静,不希望住在规划中的快速公路旁边*。

你的任务是规划一条从 Bajtocja 左上角到右下角的快速公路路线。路线只能沿着现有的道路铺设,以最小化重建成本。路线的长度和转弯次数无关紧要。

任何与快速公路相邻(包括边相邻或角相邻)的单元格中的居民都必须被驱逐。请问最少需要驱逐多少名居民?

*很久以前,一位老人因为太生气,把许多气球绑在房子上飞走了。

输入格式

第一行包含两个数字 $H$ 和 $W$ ($1 \le H, W \le 50$),表示 Bajtocja 的尺寸。 接下来的 $H$ 行描述了单元格的居住情况。每行包含一个长度为 $W$ 的字符串,由字符 '.'(空单元格)和 '#'(有人居住的单元格)组成。

输出格式

输出一个整数,表示最少需要驱逐的居民人数。

样例

输入格式 1

4 6
.##...
.#....
##....
....#.

输出格式 1

1

说明

如果你驱逐了第一列第三行的居民,你可以按如下方式修建快速公路:

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.