#P17023. [ROI 2026 Day2] 夜,街道,路灯,药房

    ID: 19312 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>2026ROI(俄罗斯)

[ROI 2026 Day2] 夜,街道,路灯,药房

Problem Description

On a long street, there are some lamp posts with nn streetlights installed. We set up a coordinate system along the street. The lamp post of the ii-th streetlight is located at coordinate xix_i. In the first six subtasks of this problem (worth 85 points in total), no two streetlights are installed on the same lamp post, i.e. all xix_i are distinct. In the last two subtasks, each lamp post can have at most two streetlights.

To light up the street, we can turn on some of the streetlights. If the ii-th streetlight is turned on, it has brightness sis_i. When it shines, starting from its lamp post, it can illuminate a continuous segment of the street with length sis_i meters. Each turned-on streetlight can be oriented either to the left or to the right. If the ii-th streetlight shines to the left, it illuminates the interval [xi−si,xi][x_i - s_i, x_i]; if it shines to the right, it illuminates the interval [xi,xi+si][x_i, x_i + s_i].

We choose a non-empty set of streetlights to illuminate a segment of the street. If it is possible to choose, for every streetlight in the set, whether it shines left or right so that the following two conditions hold at the same time, then the set is called economical:

  • The illuminated intervals can be joined into one continuous street interval.
  • No non-zero-length interval is illuminated by two or more streetlights at the same time.

The figure below shows an economical subset with two streetlights in Sample 2 and one way to illuminate a continuous interval. The brightness of each streetlight is labeled above it.

:::align{center} :::

Please compute the number of economical subsets of streetlights. Output the answer modulo 109+710^9 + 7.

Input Format

The first line contains an integer nn (1≤n≤1051 \le n \le 10^5), the number of streetlights. The next lines describe the streetlights.

Each of the next nn lines contains two integers xix_i and sis_i, representing the coordinate of the lamp post of the ii-th streetlight and its brightness, respectively (1≤xi≤5⋅1051 \le x_i \le 5 \cdot 10^5, 1≤si≤5⋅1051 \le s_i \le 5 \cdot 10^5, x1≤x2≤…≤xnx_1 \le x_2 \le \ldots \le x_n).

It is guaranteed that at most two streetlights are installed on the same lamp post, i.e. for any coordinate vv, the number of indices ii such that xi=vx_i = v is at most two.

Output Format

Output one integer: the number of economical subsets of streetlights modulo 109+710^9 + 7.

2
2 3
7 2
3
3
1 1
3 1
4 2
6
5
3 2
4 2
5 2
6 2
7 2
10
4
3 2
7 4
7 4
8 2
8
5
1 2
1 3
2 1
2 2
4 1
19

Hint

Notes

In the first sample, all three non-empty subsets of streetlights are valid.

In the second sample, all subsets are valid except the set {1,2,3}\{1, 2, 3\}.

Subtasks

Introduce a variable tt, which denotes the maximum number of streetlights that may be located at the same coordinate xix_i.

If t=1t = 1, then x1<x2<…<xnx_1 < x_2 < \ldots < x_n.

If t=2t = 2, then x1≤x2≤…≤xnx_1 \le x_2 \le \ldots \le x_n, and if xi=xi+1x_i = x_{i+1}, then xi−1<xix_{i-1} < x_i and xi+1<xi+2x_{i+1} < x_{i+2} (when the corresponding indices exist).

Subtask Points tt nn Additional Constraints Dependent Subtasks
1 10 t=1t = 1 n≤10n \le 10
2 15 For any two different lights i,ji, j, xi−si≠xjx_i - s_i \neq x_j and xi+si≠xj−sjx_i + s_i \neq x_j - s_j
3 For any two different lights i,ji, j, si≠sjs_i \neq s_j
4 For any two different lights i,ji, j, si=sjs_i = s_j
5 10 n≤1000n \le 1000 si,xi≤1000s_i, x_i \le 1000
6 20 1–5
7 10 t=2t = 2 If xi=xi+1x_i = x_{i+1}, then si≠si+1s_i \ne s_{i+1} 1–6
8 5 1–7

The translation was completed by DeepSeek V4 Pro.

Translated by ChatGPT 5