CF1619G Unusual Minesweeper

题目描述

Polycarp 非常喜欢玩扫雷游戏。最近,他发现了一个类似的游戏,也有这样的规则。 场地上有一些地雷,每个地雷的坐标 $(x_i,y_i)$ 都是已知的,每个坐标都有以秒为单位的倒计时,之后地雷就会爆炸。爆炸后,地雷会引爆所有与地雷垂直和水平距离在 $k$ 之内的地雷,结果就是我们得到了形状为"+"的爆炸。而一次爆炸可以引起新的爆炸,每次都是这样。 此外,从 $0$ 秒开始,Polycarp 可以每秒引爆任意一个地雷,连锁反应随之发生。需要注意的是,地雷会立刻爆炸并立刻引爆其它地雷。 Polycarp 想创造一个新纪录,请你帮他计算一下,他最快能在多少秒内引爆所有地雷?

输入格式

输出格式

说明/提示

![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1619G/711da0b83edef1ebd29a367a80a04b81ecd3a6be.png)Picture from examplesFirst example: - $ 0 $ second: we explode a mine at the cell $ (2, 2) $ , it does not detonate any other mine since $ k=0 $ . - $ 1 $ second: we explode the mine at the cell $ (0, 1) $ , and the mine at the cell $ (0, 0) $ explodes itself. - $ 2 $ second: we explode the mine at the cell $ (1, 1) $ , and the mine at the cell $ (1, 0) $ explodes itself. Second example: - $ 0 $ second: we explode a mine at the cell $ (2, 2) $ we get: ![](https://espresso.codeforces.com/39eed3efcd5ca0bf2cac8262b2fc289bf89e1829.png)- $ 1 $ second: the mine at coordinate $ (0, 0) $ explodes and since $ k=2 $ the explosion detonates mines at the cells $ (0, 1) $ and $ (1, 0) $ , and their explosions detonate the mine at the cell $ (1, 1) $ and there are no mines left on the field.