CF821E.Okabe and El Psy Kongroo
普及/提高-
通过率:0%
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=ai to x=bi inclusive, and is at y=ci . It is guaranteed that a1=0 , an<=k<=bn , and ai=bi−1 for 2<=i<=n . The i -th line segment forces Okabe to walk with y -value in the range 0<=y<=ci when his x value satisfies ai<=x<=bi , 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 .
输入格式
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 ai , bi , and ci ( 0<=a_{i}<b_{i}<=10^{18} , 0<=ci<=15 ) — the left and right ends of a segment, and its y coordinate.
It is guaranteed that a1=0 , an<=k<=bn , and ai=bi−1 for 2<=i<=n .
输出格式
Print the number of walks satisfying the conditions, modulo 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: