CF1774G.Segment Covering
普及/提高-
通过率:0%
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.
输入格式
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.
输出格式
For each query, output a single integer — f(li,ri)−g(li,ri) modulo 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 .