#P6477. [NOI Online #2 提高组] 子序列问题
[NOI Online #2 提高组] 子序列问题
Background
2s 512M
Problem Description
Given a positive integer sequence , , , of length . Define a function as: the number of distinct integers in the subarray whose indices are in the range . In other words, is the size of the set . This set is not a multiset, meaning all elements in the set are different.
Now, please compute . Since the answer may be very large, output the result modulo .
Input Format
The first line contains a positive integer , representing the length of the sequence.
The second line contains positive integers, separated by spaces, representing the sequence , , , .
Output Format
Only one line containing a non-negative integer, representing the answer modulo .
4
2 1 3 2
43
3
1 1 1
6
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, , and each number in the set is in the range .
Translated by ChatGPT 5