QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 128 MB 満点: 100

#17432. 逃脱

統計

一群战俘正试图从监狱逃跑。他们已经周密地计划好了如何逃离监狱本身,之后他们希望在附近的一个村庄里找到庇护所。然而,村庄(标记为 B,见下图)和监狱(标记为 A)被一个峡谷隔开,峡谷中也有士兵把守。这些士兵坐在他们的哨位上,很少走动;每个士兵的视野范围被严格限制在 100 米以内。因此,根据士兵的位置,有可能安全地穿过峡谷,在任何时刻与最近的士兵的距离都严格大于 100 米。

你需要编写一个程序,在给定峡谷的宽度和长度以及峡谷中每个士兵的坐标的情况下,并假设士兵不会改变他们的位置,首先确定战俘是否可以在不被发现的情况下穿过峡谷。如果这是不可能的,那么战俘们(已经见惯了暴力)想知道为了安全穿过峡谷,最少需要消灭多少名士兵。无论一个士兵是否能被其他士兵看到,都可以被消灭。

注意,穿过峡谷可以从任意坐标 $(0, y_s)$ 开始(其中 $0 \le y_s \le W$),并在任意坐标 $(L, y_e)$ 结束(其中 $0 \le y_e \le W$)。$y_s$ 和 $y_e$ 都不需要是整数。

输入格式

第一行包含三个整数 $L$、$W$ 和 $N$,分别表示峡谷的长度、宽度以及士兵的数量。

接下来的 $N$ 行,每行包含一对整数 $X_i$ 和 $Y_i$,表示第 $i$ 个士兵的坐标($0 \le X_i \le L$,$0 \le Y_i \le W$)。坐标以米为单位,相对于峡谷:峡谷的西南角坐标为 $(0, 0)$,东北角坐标为 $(L, W)$,如上图所示。

输出格式

输出一行一个整数,表示为了让战俘安全穿过峡谷而必须消灭的最少士兵数量。如果战俘不需要消灭任何士兵就能逃脱,程序应输出 0。

样例

输入样例 1

130 340 5
10 50
130 130
70 170
0 180
60 260

输出样例 1

1

数据范围

  • $1 \le W \le 50,000$
  • $1 \le L \le 50,000$
  • $1 \le N \le 250$

子任务

如果你的程序只能确定战俘是否需要消灭任何守卫才能逃脱,你将获得部分分数。为此,若干个测试点将被分到同一个测试组中。如果你对该测试组中的每个测试点都正确判断了是否需要消灭守卫(0 表示不需要消灭守卫,任何大于 0 的整数表示需要消灭守卫),你将获得该测试组 30% 的分数。如果你对每个测试点都正确确定了战俘逃脱所需消灭的最少守卫数量,你将获得该测试组 100% 的分数。

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.