#abc273h. Ex - Inv(0,1)ving Insert(1,0)n
Ex - Inv(0,1)ving Insert(1,0)n
Score : points
问题陈述
我们有一个由整数对组成的序列 。初始时,。
你可以对序列 进行任意多次(包括零次)以下操作:
- 选择 相邻 的两个整数对 和 ,并在它们之间插入整数对 。
对于一个由整数对组成的序列 ,我们定义函数 如下:
- 设 (使 中每个元素都被包含在 中所需的最小操作次数)。
- 我们称“ 中的每个元素都被包含在 中”是指,对于 中的所有元素 , 都属于(由 中元素构成的集合)。
- 若不存在这样的操作,则令 。
存在一个由 个整数对组成的序列 ,其中 中的所有元素两两不同。
有 种可能的连续子数组 $S_{l,r}=((a_l,b_l),(a_{l+1},b_{l+1}),\dots,(a_r,b_r))$。求这些子数组中 的和,取模 后的结果。
形式上,要求解 $\displaystyle \sum^{N} _ {l=1} \sum^{N} _ {r=l} f(S_{l,r})$,并对结果取模 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a sequence consisting of integer pairs. Initially, .
You may perform the following operation on as many (possibly zero) times as you want:
- choose adjacent two integer pairs and , and insert between them.
For a sequence consisting of integer pairs, let us define as follows:
- let (the minimum number of operations required to make every element of contained in ).
- We say that "every element of is contained in " if, for all elements contained in , is contained in (the set consisting of the elements contained in ).
- Here, if there are no such operations, let .
There is a sequence consisting of integer pairs. Here, all elements of are pairwise distinct.
There are possible consecutive subarrays $S_{l,r}=((a_l,b_l),(a_{l+1},b_{l+1}),\dots,(a_r,b_r))$ of . Find the sum, modulo , of over those subarrays.
Formally, find $\displaystyle \sum^{N} _ {l=1} \sum^{N} _ {r=l} f(S_{l,r})$, modulo .
Constraints
- or , if .
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
7
1 2
3 7
3 5
0 0
1000000000 1
0 1
6 3
Sample Output 1
3511324
- .
- We can make $((0,1),(1,0)) \rightarrow ((0,1),(1,1),(1,0)) \rightarrow ((0,1),(1,2),(1,1),(1,0))$.
- .
- .
- .
- .
- .
- .
- .
- .
- is originally contained in .
- for all not mentioned above.
- We can prove that can never contain or regardless of operations.
Therefore, the sum of is , whose remainder when divided by is .
update @ 2024/3/10 11:31:40