CF1420D.Rescue Nibel!
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 — li and ri 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 998244353.
Ori 和 Sein 克服了许多艰难的挑战,终于点亮了“遮蔽之灯”,并找到了通往“荒芜遗迹”的关键——古蒙封印(Gumon Seal)。当他们试图打开遗迹的大门时……却毫无反应。
Ori 惊讶不已,但 Sein 很快给出了原因:聪明的古蒙为这扇门增设了一道额外的防御机制。
共有 n 盏由“精灵之树”(Spirit Tree)光芒点亮的灯。Sein 知道第 i 盏灯的开启与关闭时刻分别为 li 和 ri。要打开大门,你必须从中选出 k 盏灯,使得存在某一时刻,这 k 盏灯全部处于开启状态。
当 Sein 思考该选择哪 k 盏灯时,Ori 却对另一个问题产生了兴趣:有多少种方式选出 k 盏灯,使得大门能够被打开? 有可能 Sein 的判断有误,即根本不存在满足条件的 k 盏灯。答案可能很大,请对 998244353 取模后输出。
输入格式
First line contains two integers n and k (1≤n≤3⋅105, 1≤k≤n) — total number of lamps and the number of lamps that must be turned on simultaneously.
Next n lines contain two integers li ans ri (1≤li≤ri≤109) — period of time when i-th lamp is turned on.
第一行包含两个整数 n 和 k(1≤n≤3⋅105,1≤k≤n)—— 灯的总数以及必须同时开启的灯的数量。
接下来的 n 行每行包含两个整数 li 和 ri(1≤li≤ri≤109)—— 第 i 盏灯开启的时间区间。
输出格式
Print one integer — the answer to the task modulo 998244353.
输出一个整数——该任务答案对 998244353 取模的结果。
输入输出样例
输入#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).
第一个测试用例中有九组 k 盏灯:(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)。
第二个测试用例中 k=1,因此答案为 3。
第三个测试用例中不存在满足条件的灯对。
第四个测试用例中所有灯均在时刻 3 被打开,因此答案为 1。
第五个测试用例中有七组 k 盏灯:(1,2)、(1,3)、(2,3)、(2,4)、(3,4)、(3,5)、(4,5)。
输入解题思路,AI测评打分。不知道怎么写?