#P5193. Chain Reaction Bomb Detonation
Chain Reaction Bomb Detonation
Chain Reaction Bomb Detonation
You are given n bombs on a plane, numbered from 1 to n. Each bomb is located at coordinates \((x_i,y_i)\) and has an explosion range defined by the Manhattan distance:
\[ |x - x_i| + |y - y_i| \leqslant R \]
When a bomb explodes, it will immediately trigger every other bomb whose coordinate lies within its explosion range.
Determine the minimum number of bombs that must be ignited manually so that, through the resulting chain reactions, all bombs eventually explode.
inputFormat
The first line contains two integers n
and R
, where n
is the number of bombs and R
is the explosion radius (Manhattan distance).
Each of the next n
lines contains two integers x
and y
representing the coordinates of a bomb.
It is guaranteed that all values are integers.
outputFormat
Output a single integer, which is the minimum number of bombs that must be initially ignited to trigger a chain reaction that eventually explodes all bombs.
sample
3 2
0 0
0 1
10 10
2