Unique subsequences 2 - MarisaOJ: Marisa Online Judge

Unique subsequences 2

Time limit: 1000 ms
Memory limit: 256 MB
You are given an array $A$ of $n$ elements. Count the number of non-empty unique subsequences of length $k$ of $A$. _A subsequence of a given sequence is a sequence that can be derived from the given sequence by deleting some or no elements without changing the order of the remaining elements._ ### Input - The first line contains 2 integers $n, k$. - The second line contains $n$ integers $A_i$. ### Output - Print the number of unique subsequences, modulo $123456789$. ### Constraints - $1 \le k \le n \le 2000$. - $1 \le A_i \le 2000$. ### Example Input: ``` 3 2 1 2 2 ``` Output: ``` 2 ```