309843: CF1743F. Intersection and Union

Memory Limit:512 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Intersection and Union

题意翻译

给定 $n$ 个集合 $S_i$,以 $l_i,r_i$ 的形式给出,集合的元素就是 $\{x|x\in [l_i,r_i]\cap \mathbb{N}\}$。 有三种集合间的二元运算,分别是交($\cap$)、并($\cup$)、对称差($\oplus$)。 其中对称差($A\oplus B$)的定义是 $\{x|x\in A,x\not\in B\text{或}x\in B,x\not\in A\}$。 现在有 $n-1$ 个未知的运算,$op_1,op_2,\cdots,op_{n-1}$,每个 $op_i$ 可以是交、并、对称差的任意一个。 请你对于 $op_i$ 的 $3^{n-1}$ 种设置方案,求出: $$|(((S_1\ op_1\ S_2)\ op_2\ S_3)\ op_3\ S_4)\cdots\ op_{n-1}\ S_n|$$ 之和。 其中 $|A|$ 为集合 $A$ 的大小。 $2\leq n\leq 3\times 10^5,0\leq l_i,r_i\leq 3\times 10^5$

题目描述

You are given $ n $ segments on the coordinate axis. The $ i $ -th segment is $ [l_i, r_i] $ . Let's denote the set of all integer points belonging to the $ i $ -th segment as $ S_i $ . Let $ A \cup B $ be the union of two sets $ A $ and $ B $ , $ A \cap B $ be the intersection of two sets $ A $ and $ B $ , and $ A \oplus B $ be the symmetric difference of $ A $ and $ B $ (a set which contains all elements of $ A $ and all elements of $ B $ , except for the ones that belong to both sets). Let $ [\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 $ 3^{n-1} $ ways to choose this array, calculate the sum of the following values: $ $|(((S_1\ \mathbin{op}_1\ S_2)\ \mathbin{op}_2\ S_3)\ \mathbin{op}_3\ S_4)\ \dots\ \mathbin{op}_{n-1}\ S_n| $ $ </p><p>In this expression, $ |S| $ denotes the size of the set $ S$.

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 2 \le n \le 3 \cdot 10^5 $ ). Then, $ n $ lines follow. The $ i $ -th of them contains two integers $ l_i $ and $ r_i $ ( $ 0 \le l_i \le r_i \le 3 \cdot 10^5 $ ).

输出格式


Print one integer — the sum of $ |(((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 $ [\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}] $ . Since the answer can be huge, print it modulo $ 998244353 $ .

输入输出样例

输入样例 #1

4
3 5
4 8
2 2
1 9

输出样例 #1

162

输入样例 #2

4
1 9
3 5
4 8
2 2

输出样例 #2

102

Input

题意翻译

给定 $n$ 个集合 $S_i$,以 $l_i,r_i$ 的形式给出,集合的元素就是 $\{x|x\in [l_i,r_i]\cap \mathbb{N}\}$。 有三种集合间的二元运算,分别是交($\cap$)、并($\cup$)、对称差($\oplus$)。 其中对称差($A\oplus B$)的定义是 $\{x|x\in A,x\not\in B\text{或}x\in B,x\not\in A\}$。 现在有 $n-1$ 个未知的运算,$op_1,op_2,\cdots,op_{n-1}$,每个 $op_i$ 可以是交、并、对称差的任意一个。 请你对于 $op_i$ 的 $3^{n-1}$ 种设置方案,求出: $$|(((S_1\ op_1\ S_2)\ op_2\ S_3)\ op_3\ S_4)\cdots\ op_{n-1}\ S_n|$$ 之和。 其中 $|A|$ 为集合 $A$ 的大小。 $2\leq n\leq 3\times 10^5,0\leq l_i,r_i\leq 3\times 10^5$

Output

**标题:交集与并集**

**题意翻译:**
给定 $ n $ 个集合 $ S_i $,每个集合以区间 $[l_i, r_i]$ 的形式给出,集合中的元素满足 $ x $ 属于 $ [l_i, r_i] $ 且 $ x $ 是自然数。集合间有三种二元运算:交集($\cap$)、并集($\cup$)和对立差($\oplus$)。对立差的定义是集合 $ A \oplus B $ 包含所有满足 $ x $ 属于 $ A $ 但不属于 $ B $ 或 $ x $ 属于 $ B $ 但不属于 $ A $ 的元素。

现在有 $ n-1 $ 个未知的运算符 $ op_1, op_2, \cdots, op_{n-1} $,每个 $ op_i $ 可以是交、并、对立差的任意一个。对于 $ op_i $ 的 $ 3^{n-1} $ 种设置方案,求出表达式 $ \left| \left( \left( \left( S_1 \ op_1 \ S_2 \right) \ op_2 \ S_3 \right) \ op_3 \ S_4 \right) \cdots \ op_{n-1} \ S_n \right| $ 的总和。其中 $ |A| $ 表示集合 $ A $ 的大小。

数据范围:$ 2 \leq n \leq 3 \times 10^5, 0 \leq l_i, r_i \leq 3 \times 10^5 $

**题目描述:**
给定 $ n $ 个坐标轴上的线段,第 $ i $ 个线段为 $ [l_i, r_i] $。用 $ S_i $ 表示第 $ i $ 个线段上的所有整点构成的集合。

定义 $ A \cup B $ 为集合 $ A $ 和 $ B $ 的并集,$ A \cap B $ 为集合 $ A $ 和 $ B $ 的交集,$ A \oplus B $ 为集合 $ A $ 和 $ B $ 的对称差(包含所有属于 $ A $ 或 $ B $ 但不同时属于两个集合的元素)。

设 $ [\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}] $ 是一个数组,每个元素可以是 $ \cup $, $ \oplus $, 或 $ \cap $。在所有 $ 3^{n-1} $ 种选择这个数组的方式中,计算以下值的总和:

$$ \left| \left( \left( \left( S_1 \ \mathbin{op}_1 \ S_2 \right) \ \mathbin{op}_2 \ S_3 \right) \ \mathbin{op}_3 \ S_4 \right) \ \dots \ \mathbin{op}_{n-1} \ S_n \right| $$

在这里,$ |S| $ 表示集合 $ S $ 的大小。

**输入输出格式:**

**输入格式:**
第一行包含一个整数 $ n $($ 2 \le n \le 3 \times 10^5 $)。

接下来 $ n $ 行,每行包含两个整数 $ l_i $ 和 $ r_i $($ 0 \le l_i \le r_i \le 3 \times 10^5 $)。

**输出格式:**
打印一个整数——在所有可能选择 $ [\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}] $ 方案中,表达式 $ \left| \left( \left( \left( S_1 \ \mathbin{op}_1 \ S_2 \right) \ \mathbin{op}_2 \ S_3 \right) \ \mathbin{op}_3 \ S_4 \right) \ \dots \ \mathbin{op}_{n-1} \ S_n \right| $ 的总和。由于答案可能很大,请将其模 $ 998244353 $ 后输出。

**输入输出样例:**

**输入样例 #1:**
```
4
3 5
4 8
2 2
1 9
```
**输出样例 #1:**
```
162
```

**输入样例 #2:**
```
4
1 9
3 5
4 8
2 2
```
**输出样例 #2:**
```
102
```**标题:交集与并集** **题意翻译:** 给定 $ n $ 个集合 $ S_i $,每个集合以区间 $[l_i, r_i]$ 的形式给出,集合中的元素满足 $ x $ 属于 $ [l_i, r_i] $ 且 $ x $ 是自然数。集合间有三种二元运算:交集($\cap$)、并集($\cup$)和对立差($\oplus$)。对立差的定义是集合 $ A \oplus B $ 包含所有满足 $ x $ 属于 $ A $ 但不属于 $ B $ 或 $ x $ 属于 $ B $ 但不属于 $ A $ 的元素。 现在有 $ n-1 $ 个未知的运算符 $ op_1, op_2, \cdots, op_{n-1} $,每个 $ op_i $ 可以是交、并、对立差的任意一个。对于 $ op_i $ 的 $ 3^{n-1} $ 种设置方案,求出表达式 $ \left| \left( \left( \left( S_1 \ op_1 \ S_2 \right) \ op_2 \ S_3 \right) \ op_3 \ S_4 \right) \cdots \ op_{n-1} \ S_n \right| $ 的总和。其中 $ |A| $ 表示集合 $ A $ 的大小。 数据范围:$ 2 \leq n \leq 3 \times 10^5, 0 \leq l_i, r_i \leq 3 \times 10^5 $ **题目描述:** 给定 $ n $ 个坐标轴上的线段,第 $ i $ 个线段为 $ [l_i, r_i] $。用 $ S_i $ 表示第 $ i $ 个线段上的所有整点构成的集合。 定义 $ A \cup B $ 为集合 $ A $ 和 $ B $ 的并集,$ A \cap B $ 为集合 $ A $ 和 $ B $ 的交集,$ A \oplus B $ 为集合 $ A $ 和 $ B $ 的对称差(包含所有属于 $ A $ 或 $ B $ 但不同时属于两个集合的元素)。 设 $ [\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}] $ 是一个数组,每个元素可以是 $ \cup $, $ \oplus $, 或 $ \cap $。在所有 $ 3^{n-1} $ 种选择这个数组的方式中,计算以下值的总和: $$ \left| \left( \left( \left( S_1 \ \mathbin{op}_1 \ S_2 \right) \ \mathbin{op}_2 \ S_3 \right) \ \mathbin{op}_3 \ S_4 \right) \ \dots \ \mathbin{op}_{n-1} \ S_n \right| $$ 在这里,$ |S| $ 表示集合 $ S $ 的大小。 **输入输出格式:** **输入格式:** 第一行包含一个整数 $ n $($ 2 \le n \le 3 \times 10^5 $)。 接下来 $ n $ 行,每行包含两个整数 $ l_i $ 和 $ r_i $($ 0 \le l_i \le r_i \le 3 \times 10^5 $)。 **输出格式:** 打印一个整数——在所有可能选择 $ [\mathbin{op}_1, \mathbin{op}_2, \dots, \mathbin{op}_{n-1}] $ 方案中,表达式 $ \left| \left( \left( \left( S_1 \ \mathbin{op}_1 \ S_2 \right) \ \mathbin{op}_2 \ S_3 \right) \ \mathbin{op}_3 \ S_4 \right) \ \dots \ \mathbin{op}_{n-1} \ S_n \right| $ 的总和。由于答案可能很大,请将其模 $ 998244353 $ 后输出。 **输入输出样例:** **输入样例 #1:** ``` 4 3 5 4 8 2 2 1 9 ``` **输出样例 #1:** ``` 162 ``` **输入样例 #2:** ``` 4 1 9 3 5 4 8 2 2 ``` **输出样例 #2:** ``` 102 ```

加入题单

算法标签: