#P9709. [KMOI R1] 军事行动
[KMOI R1] 军事行动
Background
$$\purple{Assemble the army, take them out, leave none alive.}$$Problem Description
The situation on the Meow Planet’s border is getting more and more tense, leading to border conflicts. The commander-in-chief of the Meow Planet’s army, Xiao Yuan, immediately launches a military operation against Planet .
The entire universe can be viewed as a 2D Cartesian coordinate system. Cities are located at , respectively.
Now Xiao Yuan commands several fleets (you may understand this as Xiao Yuan having unlimited military power) stationed at the border fortress, City . His fleets move as follows:
- If a fleet is at coordinate , then after one day it can move to , , , , , , , or .
Surrounding the outside is an asteroid belt. When a fleet is at coordinate and or or or , the fleet will crash into the asteroid belt, which is something Xiao Yuan does not want.
Now Xiao Yuan wants to attack Cities . Each time, he will dispatch a fleet from a city that has already been occupied (City also counts), send it to City , and attack it. City will be occupied on the second day after the fleet arrives.
In particular, while Xiao Yuan is sending a fleet to attack or is attacking a city, he will not dispatch another fleet. On the same day a city is occupied, he can immediately dispatch another fleet.
Xiao Yuan wants to know the minimum time needed to occupy all cities.
The attack order does not need to follow .
Input Format
The first line contains two integers , representing the number of cities and the range of the asteroid belt.
The next lines each contain two positive integers , representing the coordinates of City . It is guaranteed that .
Output Format
Output one integer , representing the minimum time required.
2 20
1 1
1 3
3
3 150
1 2
2 4
4 3
4
10 10
1 4
2 3
2 6
3 6
10 3
1 5
4 2
5 3
2 8
9 2
23
查看附件的 example4.in
查看附件的 example4.out
Hint
Explanation for Sample 1.
On day 1, the fleet arrives at position . On day 2, it reaches the position of City . On day 3, it occupies City . A total of days are used.
Explanation for Sample 2.
On day 1, the fleet reaches the position of City . On day 2, it occupies City . On day 3, it reaches the position of City . On day 4, it occupies City . A total of days are used.
Constraints
This problem uses bundled Subtask testdata.
| Subtask ID | Test Point ID | Special Property | Score | ||
|---|---|---|---|---|---|
| None | |||||
| Yes | |||||
| None |
Special property: For every , we have .
The testdata strictly guarantees that no two different cities share the same coordinates.
Translated by ChatGPT 5