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.