#P4637. [SHOI2011] 扫雷机器人

[SHOI2011] 扫雷机器人

Description

Minesweeping is an important and dangerous task on the army battlefield. For this purpose, the AL military factory specially developed a minesweeping robot. This robot is designed specifically for linear minefields. A so-called linear minefield means that all mines are buried on the same straight line. For example, in the figure, the minefield marked by black dots is a linear minefield.

0

The AL military factory’s minesweeping robot has only one method to clear mines: safe detonation. Each time, the robot chooses one mine among all detected mines to detonate. The detonated mine will in turn detonate other mines that are within its blast range. These indirectly detonated mines can further cause chain explosions. For example, in the figure, a circle radius represents a mine’s blast range. If mine 22 is detonated, mines 11 and 22 will explode; if mine 33 is detonated, all 44 mines will explode; but if mine 44 is detonated, then only mine 44 will explode.

Even for a robot, detonation is dangerous. Therefore, the buyer hopes that in real combat the robot can use a clearing plan that destroys all mines with as few detonations as possible. So the AL military factory wants to test the robot on this aspect. To evaluate the robot’s performance, the AL military factory plans to compute in advance: in a linear minefield (i.e., the input minefield), if detonations are performed randomly, the expected number of detonations needed to finish clearing all mines. This value will then be compared with the robot’s actual clearing plan to evaluate its performance.

“Random detonation” means that each time, one mine is chosen uniformly at random among all mines that have not been detonated, and then detonated. After the chain reaction caused by this detonation ends, if there are still mines that have not been detonated, repeat the above operation until all mines have been detonated.

Input Format

The first line contains a positive integer nn, the number of mines.

The next nn lines describe the mines in order of their positions, one mine per line. On line i+1i+1, there are two integers xix_i and did_i, representing the coordinate of the mine and its blast power. That is, mine ii can directly detonate mine jj if xixjdi|x_i-x_j| \le d_i. The input guarantees: xi108|x_i| \le 10^8, 1di1081 \le d_i \le 10^8.

Output Format

Output one line containing one real number, which is the answer. Round to four digits after the decimal point.

4
0 1
2 2
8 7
11 2
2.3333
3
-10 10
0 1
10 10
2.3333
2
1 10
2 100
1.0000

9
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
1000 2000
1.8889

Hint

Hint

In the problem directory, there are 1010 additional input sample files robot20111.in~robot201110.in and their corresponding output sample files robot20111.out~robot201110.out. These files satisfy all constraints in this problem, but they are not the final testdata.

Download link, password: ypbv.

Scoring

For each test point, if your output is YourAnsYourAns and the standard answer is StdAnsStdAns, then:

  • When YourAnsStdAns0.0001|YourAns-StdAns| \le 0.0001, you get 1010 points for that test point.
  • When 0.01YourAnsStdAns>0.00010.01 \ge |YourAns-StdAns| > 0.0001, you get 66 points.
  • When 0.5YourAnsStdAns>0.010.5 \ge |YourAns-StdAns| > 0.01, you get 22 points.
  • Otherwise, you get 00 points.

Constraints

Test point 11: n20n \le 20.

Test point 22: n200n \le 200, and any strategy guarantees that the number of detonations does not exceed 2020.

Test point 33: n200n \le 200.

Test points 454 \sim 5: n4000n \le 4000, and any strategy guarantees that the number of detonations does not exceed 2020.

Test points 6106 \sim 10: n4000n \le 4000.

Translated by ChatGPT 5