CSES Problemset/Sorting and Searching
Distinct Values Subsequences
#3421Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopGiven an array of integers, count the number of subsequences where each element is distinct.
A subsequence is a sequence of array elements from left to right that may have gaps.
Input
The first line has an integer : the array size.
The second line has integers : the array contents.
Output
Print the number of subsequences with distinct elements. The answer can be large, so print it modulo .
Constraints
Sample Test Cases (1)
Example 1ID: sample-1
Input
4 1 2 1 3
Expected Output
11
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
4 1 2 1 3
Expected Output
11