luogu#P5099. [USACO04OPEN] Cave Cows 4
[USACO04OPEN] Cave Cows 4
Problem Description
A vertical stone wall stands in front of Bessie, and she must climb over it.
The wall can be seen as the plane. Bessie starts at . As long as she reaches the position with ( ), the climb is considered successful.
There are ( ) stones protruding from the wall, which can be used as footholds. If the distances between two footholds in both the direction and the direction are no more than , then Bessie can climb from one foothold to the other.
Help Bessie determine whether she can climb over the wall. If she can, find the minimum number of footholds she needs to step on.
Input Format
The first line contains and .
The next lines each contain the coordinates , representing the position of a stone. Here and . It is guaranteed that does not appear.
Output Format
If Bessie can climb over the wall, output the minimum number of footholds needed (the starting point is not counted). Otherwise, output .
5 3
1 2
6 3
4 1
3 2
0 2
4
Hint
One possible route is: (0,0) -> (1,2) -> (3,2) -> (4,1) -> (6,3).
Translated by ChatGPT 5