#P10202. [湖北省选模拟 2024] 沉玉谷 / jade
[湖北省选模拟 2024] 沉玉谷 / jade
Background
If there were no gods under heaven, this would be the kingdom of humans.
Problem Description
You will preside over a ritual. The ritual uses jade stones arranged in a line, numbered from left to right as . The color of jade stone is .
In each round of the ritual, you need to choose a consecutive segment of jade stones with the same color , and sink them into the water. The immortal power value of this ritual will become , where the initial value of is .
After a segment of jade stones is sunk into the water, the jade stones on the right will shift left. At the same time, the numbering will also change, and they will be renumbered from left to right as . For example, there are jade stones with colors . At the beginning, the jade stone with color is numbered . After jade stones are sunk into the water, its number will become .
When all jade stones have been sunk into the water, the ritual is completed, and the value of at this time is the immortal power value of this ritual. How many different immortal power values are possible after the ritual is completed?
Since the answer may be very large, you only need to output the value modulo .
Input Format
The input has two lines.
The first line contains a positive integer , representing the number of jade stones.
The second line contains positive integers , where represents the color of the -th jade stone.
Output Format
Output one line with one integer, representing the number of different immortal power values modulo .
1
1
1
3
3 3 1
8
5
1 2 1 2 1
165
见选手目录下的 jade/jade4.in 与 jade/jade4.ans。
该样例满足测试点 5 ∼ 8 的限制。
见选手目录下的 jade/jade5.in 与 jade/jade5.ans。
该样例满足测试点 9 ∼ 12 的限制。
见选手目录下的 jade/jade6.in 与 jade/jade6.ans。
该样例满足测试点 13 ∼ 16 的限制。
见选手目录下的 jade/jade7.in 与 jade/jade7.ans。
Hint
Sample Explanation 3
Here are two possible immortal power values and the ways to obtain them:
-
$(1,\underline{2},1,2,1) \xrightarrow{K=202} (1,1,\underline{2},1) \xrightarrow{K=2\ 020\ 303} (\underline{1},\underline{1},1) \xrightarrow{K=20\ 203\ 030\ 102} (\underline{1}) \xrightarrow{K=202\ 030\ 301\ 020\ 101} ()$, obtaining the immortal power value as .
-
$(1,2,\underline{1},2,1) \xrightarrow{K=303} (1,\underline{2},\underline{2},1) \xrightarrow{K=3\ 030\ 203} (\underline{1},\underline{1}) \xrightarrow{K=30\ 302\ 030\ 102} ()$, obtaining the immortal power value as .
Subtasks
For all testdata, it is guaranteed that and .
| Test Point ID | Special Property | |
|---|---|---|
| None | ||
| A | ||
| B | ||
| C,D | ||
| C | ||
| D | ||
| None |
Special Property A: It is guaranteed that .
Special Property B: It is guaranteed that .
Special Property C: It is guaranteed that there do not exist such that , , and .
Special Property D: It is guaranteed that there do not exist such that .
Translated by ChatGPT 5