CF1743F.Intersection and Union

提高+/省选-

通过率:0%

时间限制:5.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

You are given nn segments on the coordinate axis. The ii-th segment is [li,ri][l_i, r_i]. Let's denote the set of all integer points belonging to the ii-th segment as SiS_i.

Let A∪BA \cup B be the union of two sets AA and BB, A∩BA \cap B be the intersection of two sets AA and BB, and A⊕BA \oplus B be the symmetric difference of AA and BB (a set which contains all elements of AA and all elements of BB, except for the ones that belong to both sets).

Let [op1,op2,…,opn−1][\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}] be an array where each element is either ∪\cup, ⊕\oplus, or ∩\cap. Over all 3n−13^{n-1} ways to choose this array, calculate the sum of the following values:

∣(((S_1mathbinop_1S_2)mathbinop_2S_3)mathbinop_3S_4)dotsmathbinop_n−1S_n∣|(((S\_1\\ \\mathbin{op}\_1\\ S\_2)\\ \\mathbin{op}\_2\\ S\_3)\\ \\mathbin{op}\_3\\ S\_4)\\ \\dots\\ \\mathbin{op}\_{n-1}\\ S\_n|

In this expression, ∣S∣|S| denotes the size of the set SS.

给你坐标轴上的 nn 条线段。第 ii 条线段为 [li,ri][l_i, r_i]。记第 ii 条线段所包含的所有整数点构成的集合为 SiS_i。

设 A∪BA \cup B 表示集合 AA 与 BB 的并集,A∩BA \cap B 表示集合 AA 与 BB 的交集,A⊕BA \oplus B 表示集合 AA 与 BB 的对称差(即包含所有属于 AA 或 BB 的元素,但不包含同时属于 AA 和 BB 的元素)。

令 [op1,op2,…,opn−1][\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}] 是一个长度为 n−1n-1 的数组,其中每个元素为 ∪\cup、⊕\oplus 或 ∩\cap 之一。对所有 3n−13^{n-1} 种选择该数组的方式,计算下列表达式的值之和:

∣(((S_1mathbinop_1S_2)mathbinop_2S_3)mathbinop_3S_4)dotsmathbinop_n−1S_n∣|(((S\_1\\ \\mathbin{op}\_1\\ S\_2)\\ \\mathbin{op}\_2\\ S\_3)\\ \\mathbin{op}\_3\\ S\_4)\\ \\dots\\ \\mathbin{op}\_{n-1}\\ S\_n|

其中,∣S∣|S| 表示集合 SS 的大小。

输入格式

The first line contains one integer nn (2≤n≤3⋅1052 \le n \le 3 \cdot 10^5).

Then, nn lines follow. The ii-th of them contains two integers lil_i and rir_i (0≤li≤ri≤3⋅1050 \le l_i \le r_i \le 3 \cdot 10^5).

第一行包含一个整数 nn(2≤n≤3⋅1052 \le n \le 3 \cdot 10^5)。

接下来有 nn 行。其中第 ii 行包含两个整数 lil_i 和 rir_i(0≤li≤ri≤3⋅1050 \le l_i \le r_i \le 3 \cdot 10^5)。

输出格式

Print one integer — the sum of ∣(((S1 op1 S2) op2 S3) op3 S4) … opn−1 Sn∣|(((S_1\ \mathbin{op}_1\ S_2)\ \mathbin{op}_2\ S_3)\ \mathbin{op}_3\ S_4)\ \dots\ \mathbin{op}_{n-1}\ S_n| over all possible ways to choose [op1,op2,…,opn−1][\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}]. Since the answer can be huge, print it modulo 998244353998244353.

输出一个整数——对所有可能的选择 [op1,op2,…,opn−1][\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}],计算 ∣(((S1 op1 S2) op2 S3) op3 S4) … opn−1 Sn∣|(((S_1\ \mathbin{op}_1\ S_2)\ \mathbin{op}_2\ S_3)\ \mathbin{op}_3\ S_4)\ \dots\ \mathbin{op}_{n-1}\ S_n| 的总和。由于答案可能非常大,请对 998244353998244353 取模后输出。

输入输出样例

  • 输入#1

    4
    3 5
    4 8
    2 2
    1 9

    输出#1

    162
  • 输入#2

    4
    1 9
    3 5
    4 8
    2 2

    输出#2

    102

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

首页