CF1774G.Segment Covering

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:256MB

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 998 244 353998\,244\,353 so that he wouldn't let her down.

ChthollyNotaSeniorious 给 DataStructures 一条数轴,其上有 mm 个互不相同的线段。定义 f(l,r)f(l,r) 为:选出偶数个线段,使得它们的并集恰好等于区间 [l,r][l,r] 的方案数;定义 g(l,r)g(l,r) 为:选出奇数个线段,使得它们的并集恰好等于区间 [l,r][l,r] 的方案数。

ChthollyNotaSeniorious 向 DataStructures 提出了 qq 个询问。每次询问中,ChthollyNotaSeniorious 会给出两个数 l,rl, r,他希望你能帮他求出 f(l,r)−g(l,r)f(l,r)-g(l,r) 对 998 244 353998\,244\,353 取模的结果,以免让她失望。

输入格式

The first line of input contains two integers mm (1≤m≤2⋅1051 \leq m \leq 2 \cdot 10^5) and qq (1≤q≤2⋅1051 \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 (1≤xi<yi≤1091 \leq x_i \lt 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 1≤i<j≤m1 \le i \lt 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 (1≤li<ri≤1091 \leq l_i \lt r_i \leq 10^9), describing a query.

输入的第一行包含两个整数 mm(1≤m≤2⋅1051 \leq m \leq 2 \cdot 10^5)和 qq(1≤q≤2⋅1051 \leq q \leq 2 \cdot 10^5),分别表示线段的数量和查询的数量。

接下来的 mm 行中,第 ii 行包含两个整数 xix_i 和 yiy_i(1≤xi<yi≤1091 \leq x_i \lt y_i \leq 10^9),表示一条线段 [xi,yi][x_i, y_i]。

保证所有线段互不相同。更准确地说,不存在满足 1≤i<j≤m1 \le i \lt j \le m 的两个下标 i,ji, j,使得 xi=xjx_i = x_j 且 yi=yjy_i = y_j。

再接下来的 qq 行中,第 ii 行包含两个整数 lil_i 和 rir_i(1≤li<ri≤1091 \leq l_i \lt r_i \leq 10^9),描述一次查询。

输出格式

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

对于每个查询,输出一个整数 — f(li,ri)−g(li,ri)f(l_i,r_i)-g(l_i,r_i) 对 998 244 353998\,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.

在第一个查询中,我们需要计算 f(1,4)−g(1,4)f(1, 4) - g(1, 4)。唯一满足并集为 [1,4][1, 4] 的线段子集是 [1,3],[2,4]{[1, 3], [2, 4]},因此 f(1,4)=1, g(1,4)=0f(1, 4) = 1,\ g(1, 4) = 0。

在第二个查询中,我们需要计算 f(1,5)−g(1,5)f(1, 5) - g(1, 5)。所有满足并集为 [1,5][1, 5] 的线段子集为 [1,3],[2,4],[3,5]{[1, 3], [2, 4], [3, 5]} 和 [1,3],[3,5]{[1, 3], [3, 5]},因此 f(1,5)=1, g(1,5)=1f(1, 5) = 1,\ g(1, 5) = 1。

输入解题思路,AI测评打分。不知道怎么写?

首页