A13842 | Rescue Nibel!
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Ori and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon Seal, the key to the Forlorn Ruins. When they tried to open the door to the ruins... nothing happened.
Ori was very surprised, but Sein gave the explanation quickly: clever Gumon decided to make an additional defence for the door.
There are $n$ lamps with Spirit Tree's light. Sein knows the time of turning on and off for the $i$ -th lamp — $l_i$ and $r_i$ respectively. To open the door you have to choose $k$ lamps in such a way that there will be a moment of time when they all will be turned on.
While Sein decides which of the $k$ lamps to pick, Ori is interested: how many ways there are to pick such $k$ lamps that the door will open? It may happen that Sein may be wrong and there are no such $k$ lamps. The answer might be large, so print it modulo $998\,244\,353$ .
Ori was very surprised, but Sein gave the explanation quickly: clever Gumon decided to make an additional defence for the door.
There are $n$ lamps with Spirit Tree's light. Sein knows the time of turning on and off for the $i$ -th lamp — $l_i$ and $r_i$ respectively. To open the door you have to choose $k$ lamps in such a way that there will be a moment of time when they all will be turned on.
While Sein decides which of the $k$ lamps to pick, Ori is interested: how many ways there are to pick such $k$ lamps that the door will open? It may happen that Sein may be wrong and there are no such $k$ lamps. The answer might be large, so print it modulo $998\,244\,353$ .
输入格式
First line contains two integers $n$ and $k$ ( $1 \le n \le 3 \cdot 10^5$ , $1 \le k \le n$ ) — total number of lamps and the number of lamps that must be turned on simultaneously.
Next $n$ lines contain two integers $l_i$ ans $r_i$ ( $1 \le l_i \le r_i \le 10^9$ ) — period of time when $i$ -th lamp is turned on.
Next $n$ lines contain two integers $l_i$ ans $r_i$ ( $1 \le l_i \le r_i \le 10^9$ ) — period of time when $i$ -th lamp is turned on.
输出格式
Print one integer — the answer to the task modulo $998\,244\,353$ .
输入输出样例
输入 #1
7 3 1 7 3 8 4 5 6 7 1 3 5 10 8 9
输出 #1
9
输入 #2
3 1 1 1 2 2 3 3
输出 #2
3
输入 #3
3 2 1 1 2 2 3 3
输出 #3
0
输入 #4
3 3 1 3 2 3 3 3
输出 #4
1
输入 #5
5 2 1 3 2 4 3 5 4 6 5 7
输出 #5
7
In first test case there are nine sets of $k$ lamps: $(1, 2, 3)$ , $(1, 2, 4)$ , $(1, 2, 5)$ , $(1, 2, 6)$ , $(1, 3, 6)$ , $(1, 4, 6)$ , $(2, 3, 6)$ , $(2, 4, 6)$ , $(2, 6, 7)$ .
In second test case $k=1$ , so the answer is 3.
In third test case there are no such pairs of lamps.
In forth test case all lamps are turned on in a time $3$ , so the answer is 1.
In fifth test case there are seven sets of $k$ lamps: $(1, 2)$ , $(1, 3)$ , $(2, 3)$ , $(2, 4)$ , $(3, 4)$ , $(3, 5)$ , $(4, 5)$ .
In second test case $k=1$ , so the answer is 3.
In third test case there are no such pairs of lamps.
In forth test case all lamps are turned on in a time $3$ , so the answer is 1.
In fifth test case there are seven sets of $k$ lamps: $(1, 2)$ , $(1, 3)$ , $(2, 3)$ , $(2, 4)$ , $(3, 4)$ , $(3, 5)$ , $(4, 5)$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted