A10997 | Okabe and El Psy Kongroo
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $10^{9}+7$ .
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 $10^{9}+7$ .
输入格式
The first line of input contains the integers $n$ and $k$ ( $1<=n<=100$ , $1<=k<=10^{18}$ ) — 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}<=10^{18}$ , $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$ .
The next $n$ lines contain three space-separated integers $a_{i}$ , $b_{i}$ , and $c_{i}$ ( $0<=a_{i}<b_{i}<=10^{18}$ , $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$ .
输出格式
Print the number of walks satisfying the conditions, modulo $1000000007$ ( $10^{9}+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:
- 
- 
- 
- 
- 
- 
- 
- 
The graph above corresponds to sample 2. There is only one walk for Okabe to reach $(3,0)$ . After this, the possible walks are:
- 
- 
- 
- 
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted