QOJ.ac

QOJ

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

#12745. 王国之旅

Statistics

从前,有一个由一位贤明的国王统治的王国。在他统治的四十三年后,通过成功的军事行动和娴熟的外交手段,王国变成了一个无限平坦的二维平面。这种王国形态极大地简化了旅行,因为这里没有边界。

王国计划举办一场盛大的节日庆典。全国有 $n$ 个地点供人们聚集。由于国王想更近距离地观察他的子民,他下令在这些地点之间进行一次旅行。他希望在每一个地点都发表一次演讲。最初,他的旅行路线被设计为一条折线 $p: p_1 \to p_2 \to \dots \to p_n$。

国王不仅贤明,而且年事已高。因此,他的助手们想出了一个主意:跳过一些地点,以减少国王发表演讲的次数。新的旅行计划必须是 $p$ 的一个子序列构成的折线,起点为 $p_1$,终点为 $p_n$。形式化地,即 $p_{i_1} \to p_{i_2} \to \dots \to p_{i_m}$,其中 $1 = i_1 < i_2 < \dots < i_m = n$。助手们知道,如果对于某个 $k$(满足 $i_k < j < i_{k+1}$),点 $p_j$ 到线段 $p_{i_k} \to p_{i_{k+1}}$ 的距离超过了 $d$,那么国王就不会允许跳过地点 $j$。

原始路线

新路线

请帮助助手们找到包含最少地点数量的新路线。

输入格式

输入文件的第一行包含两个整数 $n$ 和 $d$ —— 初始旅行计划中的地点数量以及允许跳过地点的最大距离($2 \le n \le 2000; 1 \le d \le 10^6$)。

接下来的 $n$ 行描述了这次旅行。第 $i$ 行包含两个整数 $x_i$ 和 $y_i$ —— 点 $p_i$ 的坐标。坐标的绝对值不超过 $10^6$。任意两点不重合。

输出格式

输出国王将访问的最少地点数量。保证对于 $d \pm 10^{-4}$ 的范围,答案是一致的。

样例

样例输入 1

5 2
2 6
8 2
14 2
12 9
13 8

样例输出 1

3

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.