atcoder#ARC125D. [ARC125D] Unique Subsequence
[ARC125D] Unique Subsequence
Score : points
Problem Statement
Given is a sequence of integers .
Find the number of non-empty subsequences of satisfying the following condition, modulo .
- There is only one way to extract from . Formally, there uniquely exists a sequence of indices A_{idx(i)}=s_i$ (), where .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 2 1
5
The following five subsequences satisfy the condition.
The subsequence does not satisfy the condition since there are two ways to extract it.
4
4 2 1 3
15
12
1 2 3 6 9 2 3 3 9 6 1 6
1178