QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22374. 激光电话

Statistics

奶牛们有了新的激光通信系统,可以在牧场里闲聊。牧场建模为 $W \times H$ 个点的网格($1 \le W \le 100; 1 \le H \le 100$)。

系统需要某种视线连通才能维持通信。当然,牧场里的岩石和树木会阻断通信,不过奶牛们购买了斜放的镜子(下图中的 / 和 \),能使激光转向 $90$ 度。下面的地图说明了这个问题。

图中 $H=8$、$W=7$。两头通信的奶牛标为 $C$,岩石和其他障碍物标为 *:

7 . . . . . . .         7 . . . . . . .
6 . . . . . . C         6 . . . . . /-C
5 . . . . . . *         5 . . . . . | *
4 * * * * * . *         4 * * * * * | *
3 . . . . * . .         3 . . . . * | .
2 . . . . * . .         2 . . . . * | .
1 . C . . * . .         1 . C . . * | .
0 . . . . . . .         0 . \-------/ .
  0 1 2 3 4 5 6           0 1 2 3 4 5 6

求维持两头奶牛之间激光通信所需安装的最少镜子数量 $M$。给定测试数据保证总能做到。

输入格式

  • 第 1 行:两个以空格分隔的整数 $W$ 和 $H$。
  • 第 $2,\ldots,H+1$ 行:整个牧场。

输出格式

  • 第 1 行:一个整数 $M$。

样例

输入格式 1

7 8
.......
......C
......*
*****.*
....*..
....*..
.C..*..
.......

输出格式 1

3

题目署名:Rob Kolstad,2008

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.