#P1370. Charlie 的云笔记序列
Charlie 的云笔记序列
Description
One day, Charlie abstracts his collected problems into a sequence. .
Let denote the subarray of the sequence from the -th element to the -th element, where . Formally, $a[l:r] = \{a_l, a_{l+1}, a_{l+2}, \cdots, a_{r-1}, a_r\}$. For example, if , then .
Charlie defines a function on the sequence , which denotes the number of essentially different subsequences of . In particular, the empty sequence is also counted as one essentially different subsequence.
A subsequence of is defined as $[a_{i_1}, a_{i_2}, a_{i_3}, \cdots, a_{i_{k-1}}, a_{i_k}]$, where $l \le i_1 < i_2 < i_3 < \cdots < i_{k-1} < i_k \le r$. For example, if , then is a subsequence of .
A sequence of length and a sequence of length are called essentially different if and only if , or there exists such that . Otherwise, the two sequences are called essentially the same. For example, and are essentially different; and are also essentially different; while and are essentially the same.
For example, let . Then , because has subsequences: .
Now Charlie wants to know the value of . Since this number may be large, please output it modulo (, a prime).
Input Format
The first line contains an integer , denoting the length of the sequence .
The second line contains integers, denoting .
Output Format
One line containing a single integer: the value of modulo .
8
1 9 9 8 0 3 2 1
814
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
- For of the testdata, , .
oiinhand 3.0 is under development.
This will be a must-have tool for OIers. It not only aggregates resources (problems, solutions) from all major OJs across the web, but also allows users to store code they have been judged on other OJs, and it has a very considerate cloud notes feature to help everyone practice with maximum efficiency.
soha is soliciting feedback here, with rewards! http://www.wenjuan.com/s/M7fqIv/
Translated by ChatGPT 5
京公网安备 11011102002149号