QOJ.ac

QOJ

时间限制: 2 s 内存限制: 256 MB 总分: 10

#1384. Miny [B]

统计

在拜托(Bajtów)的军事训练场上,有 $n$ 枚地雷被放置在一条直线上。每枚地雷位于不同的位置,并拥有各自的爆炸半径。当一枚地雷被引爆后,它会自动引爆其爆炸范围内所有尚未爆炸的地雷。我们称地雷 $a$ 在地雷 $b$ 的爆炸范围内,当且仅当它们之间的距离不超过地雷 $b$ 的爆炸半径。

中士 Bajtomir 想要进行一项实验。他将选择地雷的任意一个子集(可以是空集),并下令在同一时刻手动引爆这些地雷。实验的结果是所有爆炸的地雷集合——无论是通过手动引爆还是通过其他地雷的连锁反应而爆炸。

Bajtomir 可能得到多少种不同的实验结果?如果两个实验结果中爆炸的地雷集合相同,则认为它们是相同的。由于结果数量可能很大,请输出其对 $10^9 + 7$ 取模后的结果。

输入格式

输入的第一行包含一个自然数 $n$ ($1 \le n \le 300\,000$),表示地雷的数量。接下来的 $n$ 行,每行包含两个自然数 $a_i$ 和 $r_i$ ($0 \le a_i \le 10^{18}, 0 \le r_i \le 10^{18}$),分别表示第 $i$ 枚地雷在直线上的位置及其爆炸半径。你可以假设 $a_1 < a_2 < a_3 < \dots < a_n$。

输出格式

输出 Bajtomir 通过手动引爆所选子集后,可能得到的不同实验结果的数量,对 $10^9 + 7$ 取模。

样例

输入 1

4
0 2
2 0
3 2
7 4

输出 1

7

说明 1

可以得到 7 种不同的实验结果: 结果 {}(空集),如果不手动引爆任何地雷; 结果 {1, 2}(地雷 1 和 2),如果仅手动引爆地雷 1; 结果 {1, 2, 3},如果手动引爆地雷 1 和 3; 结果 {1, 2, 3, 4},如果手动引爆地雷 1 和 4; 结果 {2},如果仅手动引爆地雷 2; 结果 {2, 3},如果仅手动引爆地雷 3; * 结果 {2, 3, 4},如果仅手动引爆地雷 4。

请注意,同一个实验结果通常可以通过多种不同的方式获得——例如,如果我们手动引爆地雷 1 和 2,同样会得到结果 {1, 2}。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.