luogu#P1370. Charlie 的云笔记序列
Charlie 的云笔记序列
Background
Charlie is a loyal fan of oiinhand. He has the habit of using oih cloud notes to record his problem solutions. Only bit-by-bit accumulation can leave his own footprints.
Does oih cloud notes have any special features?
oih’s admin soha says that the current cloud notes in oih2 are relatively simple, but the new cloud notes under development for oih3 will be the best tool in the world for OIers to store their notes.
First, the new cloud notes support Markdown with real-time preview; inserting formulas and images is not a problem. It saves automatically in real time, so you do not need to worry about sudden power outages or document loss, and you can view it anywhere!
Second, it can generate a problem-solution template summary with one click, so you no longer need to copy and paste. Super convenient!
Moreover, cloud notes can be shared with other classmates for mutual improvement. After finishing a note, you can submit it to Luogu with one click!
However, Charlie’s favorite feature is oih’s problem collection. He has now collected a series of problems, but he feels it is not enough, so he is playing with this feature.
Problem 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