A11638 | Coins Exhibition
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Arkady and Kirill visited an exhibition of rare coins. The coins were located in a row and enumerated from left to right from $1$ to $k$ , each coin either was laid with its obverse (front) side up, or with its reverse (back) side up.
Arkady and Kirill made some photos of the coins, each photo contained a segment of neighboring coins. Akrady is interested in obverses, so on each photo made by him there is at least one coin with obverse side up. On the contrary, Kirill is interested in reverses, so on each photo made by him there is at least one coin with its reverse side up.
The photos are lost now, but Arkady and Kirill still remember the bounds of the segments of coins each photo contained. Given this information, compute the remainder of division by $10^{9}+7$ of the number of ways to choose the upper side of each coin in such a way, that on each Arkady's photo there is at least one coin with obverse side up, and on each Kirill's photo there is at least one coin with reverse side up.
Arkady and Kirill made some photos of the coins, each photo contained a segment of neighboring coins. Akrady is interested in obverses, so on each photo made by him there is at least one coin with obverse side up. On the contrary, Kirill is interested in reverses, so on each photo made by him there is at least one coin with its reverse side up.
The photos are lost now, but Arkady and Kirill still remember the bounds of the segments of coins each photo contained. Given this information, compute the remainder of division by $10^{9}+7$ of the number of ways to choose the upper side of each coin in such a way, that on each Arkady's photo there is at least one coin with obverse side up, and on each Kirill's photo there is at least one coin with reverse side up.
输入格式
The first line contains three integers $k$ , $n$ and $m$ ( $1<=k<=10^{9}$ , $0<=n,m<=10^{5}$ ) — the total number of coins, the number of photos made by Arkady, and the number of photos made by Kirill, respectively.
The next $n$ lines contain the descriptions of Arkady's photos, one per line. Each of these lines contains two integers $l$ and $r$ ( $1<=l<=r<=k$ ), meaning that among coins from the $l$ -th to the $r$ -th there should be at least one with obverse side up.
The next $m$ lines contain the descriptions of Kirill's photos, one per line. Each of these lines contains two integers $l$ and $r$ ( $1<=l<=r<=k$ ), meaning that among coins from the $l$ -th to the $r$ -th there should be at least one with reverse side up.
The next $n$ lines contain the descriptions of Arkady's photos, one per line. Each of these lines contains two integers $l$ and $r$ ( $1<=l<=r<=k$ ), meaning that among coins from the $l$ -th to the $r$ -th there should be at least one with obverse side up.
The next $m$ lines contain the descriptions of Kirill's photos, one per line. Each of these lines contains two integers $l$ and $r$ ( $1<=l<=r<=k$ ), meaning that among coins from the $l$ -th to the $r$ -th there should be at least one with reverse side up.
输出格式
Print the only line — the number of ways to choose the side for each coin modulo $10^{9}+7=1000000007$ .
输入输出样例
输入 #1
5 2 2 1 3 3 5 2 2 4 5
输出 #1
8
输入 #2
5 3 2 1 3 2 2 3 5 2 2 4 5
输出 #2
0
输入 #3
60 5 7 1 3 50 60 1 60 30 45 20 40 4 5 6 37 5 18 50 55 22 27 25 31 44 45
输出 #3
732658600
In the first example the following ways are possible ('O' — obverse, 'R' — reverse side):
- OROOR,
- ORORO,
- ORORR,
- RROOR,
- RRORO,
- RRORR,
- ORROR,
- ORRRO.
In the second example the information is contradictory: the second coin should have obverse and reverse sides up at the same time, that is impossible. So, the answer is $0$ .
- OROOR,
- ORORO,
- ORORR,
- RROOR,
- RRORO,
- RRORR,
- ORROR,
- ORRRO.
In the second example the information is contradictory: the second coin should have obverse and reverse sides up at the same time, that is impossible. So, the answer is $0$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted