#P10342. [THUSC 2019] 数列
[THUSC 2019] 数列
Problem Description
Define the value of a sequence of length as: $val = \max \limits_{1 \le i \le k}\{i \times f(i,k)\}$.
Here, denotes the number of distinct values within the interval .
Given a sequence of length , compute the sum of values over all contiguous subintervals. Treat each contiguous subinterval as an independent sequence; the computed value is exactly the value of that subinterval.
Let be the number of distinct values appearing in the sequence.
Input Format
The first line contains an integer .
The second line contains positive integers , describing the value at each position of the sequence.
For all input data, it holds that .
Output Format
Output one integer in the first line, representing the answer modulo .
4
12 23 23 45
23
Hint
[Sample Explanation 1]
All intervals of length contribute to the answer.
All intervals of length contribute to the answer.
The interval contributes to the answer.
The interval contributes to the answer.
The interval contributes to the answer.
Therefore, the answer is .
[Sample 2]
See the attached files 2.in/ans.
[Sample 3]
See the attached files 3.in/ans.
[Sample 4]
See the attached files 4.in/ans.
[Sample 5]
See the attached files 5.in/ans.
[Subtasks]
| Subtask ID | Constraints | Score | |||
|---|---|---|---|---|---|
| 1 | None | 13 | |||
| 2 | No equal values will appear | 15 | |||
| 3 | In $[1,m][m+1,2m]\dots[\lfloor\frac{n}{m}\rfloor\times m + 1,n]$, each interval has no repeated values | 21 | |||
| 4 | None | 24 | |||
| 5 | 27 | ||||
Translated by ChatGPT 5