A10646 | Slalom
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Little girl Masha likes winter sports, today she's planning to take part in slalom skiing.
The track is represented as a grid composed of $n×m$ squares. There are rectangular obstacles at the track, composed of grid squares. Masha must get from the square $(1,1)$ to the square $(n,m)$ . She can move from a square to adjacent square: either to the right, or upwards. If the square is occupied by an obstacle, it is not allowed to move to that square.
One can see that each obstacle can actually be passed in two ways: either it is to the right of Masha's path, or to the left. Masha likes to try all ways to do things, so she would like to know how many ways are there to pass the track. Two ways are considered different if there is an obstacle such that it is to the right of the path in one way, and to the left of the path in the other way.
Help Masha to find the number of ways to pass the track. The number of ways can be quite big, so Masha would like to know it modulo $10^{9}+7$ .
The pictures below show different ways to pass the track in sample tests. 
The track is represented as a grid composed of $n×m$ squares. There are rectangular obstacles at the track, composed of grid squares. Masha must get from the square $(1,1)$ to the square $(n,m)$ . She can move from a square to adjacent square: either to the right, or upwards. If the square is occupied by an obstacle, it is not allowed to move to that square.
One can see that each obstacle can actually be passed in two ways: either it is to the right of Masha's path, or to the left. Masha likes to try all ways to do things, so she would like to know how many ways are there to pass the track. Two ways are considered different if there is an obstacle such that it is to the right of the path in one way, and to the left of the path in the other way.
Help Masha to find the number of ways to pass the track. The number of ways can be quite big, so Masha would like to know it modulo $10^{9}+7$ .
The pictures below show different ways to pass the track in sample tests. 
输入格式
The first line of input data contains three positive integers: $n$ , $m$ and $k$ ( $3<=n,m<=10^{6}$ , $0<=k<=10^{5}$ ) — the size of the track and the number of obstacles.
The following $k$ lines contain four positive integers each: $x_{1}$ , $y_{1}$ , $x_{2}$ , $y_{2}$ ( $1<=x_{1}<=x_{2}<=n$ , $1<=y_{1}<=y_{2}<=m$ ) — coordinates of bottom left, and top right squares of the obstacle.
It is guaranteed that there are no obstacles at squares $(1,1)$ and $(n,m)$ , and no obstacles overlap (but some of them may touch).
The following $k$ lines contain four positive integers each: $x_{1}$ , $y_{1}$ , $x_{2}$ , $y_{2}$ ( $1<=x_{1}<=x_{2}<=n$ , $1<=y_{1}<=y_{2}<=m$ ) — coordinates of bottom left, and top right squares of the obstacle.
It is guaranteed that there are no obstacles at squares $(1,1)$ and $(n,m)$ , and no obstacles overlap (but some of them may touch).
输出格式
Output one integer — the number of ways to pass the track modulo $10^{9}+7$ .
输入输出样例
输入 #1
3 3 0
输出 #1
1
输入 #2
4 5 1 2 2 3 4
输出 #2
2
输入 #3
5 5 3 2 2 2 3 4 2 5 2 4 4 4 4
输出 #3
3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted