CF1774G.Segment Covering
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
ChthollyNotaSeniorious gives DataStructures a number axis with m distinct segments on it. Let f(l,r) be the number of ways to choose an even number of segments such that the union of them is exactly [l,r], and g(l,r) be the number of ways to choose an odd number of segments such that the union of them is exactly [l,r].
ChthollyNotaSeniorious asked DataStructures q questions. In each query, ChthollyNotaSeniorious will give DataStructures two numbers l,r, and now he wishes that you can help him find the value f(l,r)−g(l,r) modulo 998244353 so that he wouldn't let her down.
ChthollyNotaSeniorious 给 DataStructures 一条数轴,其上有 m 个互不相同的线段。定义 f(l,r) 为:选出偶数个线段,使得它们的并集恰好等于区间 [l,r] 的方案数;定义 g(l,r) 为:选出奇数个线段,使得它们的并集恰好等于区间 [l,r] 的方案数。
ChthollyNotaSeniorious 向 DataStructures 提出了 q 个询问。每次询问中,ChthollyNotaSeniorious 会给出两个数 l,r,他希望你能帮他求出 f(l,r)−g(l,r) 对 998244353 取模的结果,以免让她失望。
输入格式
The first line of input contains two integers m (1≤m≤2⋅105) and q (1≤q≤2⋅105) — the number of segments and queries, correspondingly.
The i-th of the next m lines contains two integers xi and yi (1≤xi<yi≤109), denoting a segment [xi,yi].
It is guaranteed that all segments are distinct. More formally, there do not exist two numbers i,j with 1≤i<j≤m such that xi=xj and yi=yj.
The i-th of the next q lines contains two integers li and ri (1≤li<ri≤109), describing a query.
输入的第一行包含两个整数 m(1≤m≤2⋅105)和 q(1≤q≤2⋅105),分别表示线段的数量和查询的数量。
接下来的 m 行中,第 i 行包含两个整数 xi 和 yi(1≤xi<yi≤109),表示一条线段 [xi,yi]。
保证所有线段互不相同。更准确地说,不存在满足 1≤i<j≤m 的两个下标 i,j,使得 xi=xj 且 yi=yj。
再接下来的 q 行中,第 i 行包含两个整数 li 和 ri(1≤li<ri≤109),描述一次查询。
输出格式
For each query, output a single integer — f(li,ri)−g(li,ri) modulo 998244353.
对于每个查询,输出一个整数 — f(li,ri)−g(li,ri) 对 998244353 取模的结果。
输入输出样例
输入#1
4 2 1 3 4 6 2 4 3 5 1 4 1 5
输出#1
1 0
说明/提示
In the first query, we have to find f(1,4)−g(1,4). The only subset of segments with union [1,4] is [1,3],[2,4], so f(1,4)=1,g(1,4)=0.
In the second query, we have to find f(1,5)−g(1,5). The only subsets of segments with union [1,5] are [1,3],[2,4],[3,5] and [1,3],[3,5], so f(1,5)=1,g(1,5)=1.
在第一个查询中,我们需要计算 f(1,4)−g(1,4)。唯一满足并集为 [1,4] 的线段子集是 [1,3],[2,4],因此 f(1,4)=1, g(1,4)=0。
在第二个查询中,我们需要计算 f(1,5)−g(1,5)。所有满足并集为 [1,5] 的线段子集为 [1,3],[2,4],[3,5] 和 [1,3],[3,5],因此 f(1,5)=1, g(1,5)=1。
输入解题思路,AI测评打分。不知道怎么写?