
Harambe, a noble Gorilla Knight, is on a dangerous quest to preserve Gorilla all over the Galaxy. Luckily, he is with Fax McClad, Croneria's most protective bounty hunter.
The two are currently being chased by the Royal Guards (armed with deadly Gorilla guns) in the forests of Radonia. Harambe and Fax McClad are after the Neo Gorilla Cyclone Jet Gorilla Cannon (NGCJGC). Harambe wishes to destroy this devastating interplanetary cannon that can wipe out all Gorilla-kind. Note that only Harambe can destroy this cannon, as he possesses the strength of a mighty Gorilla to do so.
There are many Royal Guards stationed around the cannon. The forests of Radonia can be modelled with a grid with lines
Note that Harambe can only move vertically and horizontally along grid lines. Additionally, any move he makes must bring him closer to the cannon since in Gorilla culture, it is considered cowardly to increase your distance from the enemy.
Luckily, Fax McClad is there to take out the guards. Fax McClad can take out as many guards as he wishes in an instant. However, Fax McClad is very lazy tired and he wants to do as little work as possible. Thus, it is your job to determine the minimum number of guards that Fax McClad must eliminate in order for Harambe to reach the cannon unscathed. Can you help Fax and Harambe?
Constraints
For all subtasks:
The absolute value of any coordinate will not exceed
Subtask 1 [10%]
Subtask 2 [20%]
The absolute value of any coordinate will not exceed
Subtask 3 [30%]
The absolute value of any coordinate will not exceed
Subtask 4 [40%]
No additional constraints.
Input Specification
The first line will contain the integers
The next line will contain
The next
Output Specification
Output an integer indicating the minimum number of guards that Fax McClad must eliminate so that Harambe can destroy the Neo Gorilla Cyclone Jet Gorilla Cannon.
Sample Input
5 2
4
4 2 0
4 1 0
4 0 0
2 1 1
Sample Output
2
Explanation for Sample Output
In the diagram, the black point represents Harambe's initial starting point and the red points/regions represent the guards and their ranges. Fax must eliminate guard 4 and either guard 1, 2, or 3 so that Harambe can reach
Comments
can there be negative coordinates?
Yes.
what is considered closer? manhattan distance?
Yes.