CF821E.Okabe and El Psy Kongroo
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to know how many different walks he can take in his city safely. Okabe's city can be represented as all points (x, y) such that x and y are non-negative. Okabe starts at the origin (point (0, 0)), and needs to reach the point (k, 0). If Okabe is currently at the point (x, y), in one step he can go to (x + 1, y + 1), (x + 1, y), or (x + 1, y - 1).
Additionally, there are n horizontal line segments, the i-th of which goes from x = a__i to x = b__i inclusive, and is at y = c__i. It is guaranteed that _a_1 = 0, a__n ≤ k ≤ b__n, and a__i = b__i - 1 for 2 ≤ i ≤ n. The i-th line segment forces Okabe to walk with y-value in the range 0 ≤ y ≤ c__i when his x value satisfies a__i ≤ x ≤ b__i, or else he might be spied on. This also means he is required to be under two line segments when one segment ends and another begins.
Okabe now wants to know how many walks there are from the origin to the point (k, 0) satisfying these conditions, modulo 109 + 7.
Okabe 喜欢散步,但知道“组织”的间谍可能无处不在;因此,他想知道在自己的城市中,他能安全地走出多少种不同的路径。Okabe 的城市可以表示为所有满足 x 和 y 均为非负整数的点 (x,y)。Okabe 从原点(即点 (0,0))出发,需到达点 (k,0)。若 Okabe 当前位于点 (x,y),则他在一步之内可移动至以下三个点之一:(x+1,y+1)、(x+1,y) 或 (x+1,y−1)。
此外,还有 n 条水平线段,其中第 i 条线段从 x=ai 延伸至 x=bi(含端点),且位于 y=ci 处。题目保证 a1=0,an≤k≤bn,且对所有 2≤i≤n,均有 ai=bi−1。第 i 条线段要求:当 Okabe 的横坐标 x 满足 ai≤x≤bi 时,其纵坐标 y 必须满足 0≤y≤ci,否则他可能被间谍发现。这也意味着:当一条线段结束而另一条线段开始时(即在 x=bi=ai+1 处),Okabe 必须同时满足这两条线段所限定的 y 范围。
现在,Okabe 想知道:从原点 (0,0) 出发、到达点 (k,0) 且满足上述所有约束条件的路径总数(对 109+7 取模)。
输入格式
The first line of input contains the integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 1018) — the number of segments and the destination x coordinate.
The next n lines contain three space-separated integers a__i, b__i, and c__i (0 ≤ a__i < b__i ≤ 1018, 0 ≤ c__i ≤ 15) — the left and right ends of a segment, and its y coordinate.
It is guaranteed that _a_1 = 0, a__n ≤ k ≤ b__n, and a__i = b__i - 1 for 2 ≤ i ≤ n.
输入的第一行包含两个整数 n 和 k(1≤n≤100,1≤k≤1018)—— 分别表示线段的数量以及目标点的 x 坐标。
接下来的 n 行每行包含三个用空格分隔的整数 ai、bi 和 ci(0≤ai<bi≤1018,0≤ci≤15)—— 分别表示第 i 条线段的左端点、右端点及其 y 坐标。
保证 a1=0,an≤k≤bn,且对所有 2≤i≤n 有 ai=bi−1。
输出格式
Print the number of walks satisfying the conditions, modulo 1000000007 (109 + 7).
输出满足条件的路径数量,对 1000000007(即 109+7)取模。
输入输出样例
输入#1
1 3 0 3 3
输出#1
4
输入#2
2 6 0 3 0 3 10 2
输出#2
4
说明/提示

The graph above corresponds to sample 1. The possible walks are:

The graph above corresponds to sample 2. There is only one walk for Okabe to reach (3, 0). After this, the possible walks are:

上图对应样例 1。可能的路径有:

上图对应样例 2。Okabe 到达点 (3,0) 的路径仅有一条。此后,可能的路径有:
输入解题思路,AI测评打分。不知道怎么写?







