CF1774G.Segment Covering

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

ChthollyNotaSeniorious gives DataStructures a number axis with mm distinct segments on it. Let f(l,r)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][l,r] , and g(l,r)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][l,r] .

ChthollyNotaSeniorious asked DataStructures qq questions. In each query, ChthollyNotaSeniorious will give DataStructures two numbers l,rl, r , and now he wishes that you can help him find the value f(l,r)g(l,r)f(l,r)-g(l,r) modulo 998244353998\,244\,353 so that he wouldn't let her down.

输入格式

The first line of input contains two integers mm ( 1m21051 \leq m \leq 2 \cdot 10^5 ) and qq ( 1q21051 \leq q \leq 2 \cdot 10^5 ) — the number of segments and queries, correspondingly.

The ii -th of the next mm lines contains two integers xix_i and yiy_i ( 1xi<yi1091 \leq x_i < y_i \leq 10^9 ), denoting a segment [xi,yi][x_i, y_i] .

It is guaranteed that all segments are distinct. More formally, there do not exist two numbers i,ji, j with 1i<jm1 \le i < j \le m such that xi=xjx_i = x_j and yi=yjy_i = y_j .

The ii -th of the next qq lines contains two integers lil_i and rir_i ( 1li<ri1091 \leq l_i < r_i \leq 10^9 ), describing a query.

输出格式

For each query, output a single integer — f(li,ri)g(li,ri)f(l_i,r_i)-g(l_i,r_i) modulo 998244353998\,244\,353 .

输入输出样例

  • 输入#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)f(1, 4) - g(1, 4) . The only subset of segments with union [1,4][1, 4] is {[1,3],[2,4]}\{[1, 3], [2, 4]\} , so f(1,4)=1,g(1,4)=0f(1, 4) = 1, g(1, 4) = 0 .

In the second query, we have to find f(1,5)g(1,5)f(1, 5) - g(1, 5) . The only subsets of segments with union [1,5][1, 5] are {[1,3],[2,4],[3,5]}\{[1, 3], [2, 4], [3, 5]\} and {[1,3],[3,5]}\{[1, 3], [3, 5]\} , so f(1,5)=1,g(1,5)=1f(1, 5) = 1, g(1, 5) = 1 .

首页