A15379 | Intersection and Union
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$$$.
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$ ).
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted