Codeforces Round 542 [Alex Lopashev Thanks-Round] (Div. 1)
D
Isolation
Codeforces
2900
原题
← CE →
翻译中…

Find the number of ways to divide an array $a$ of $n$ integers into any number of disjoint non-empty segments so that, in each segment, there exist at most $k$ distinct integers that appear exactly once.

翻译中…

Since the answer can be large, find it modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $n$ and $k$ ($1 \leq k \leq n \leq 10^5$) — the number of elements in the array $a$ and the restriction from the statement.

翻译中…

The following line contains $n$ space-separated integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq n$) — elements of the array $a$.

翻译中…

Output

翻译中…

The first and only line contains the number of ways to divide an array $a$ modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first sample, the three possible divisions are as follows.

翻译中…
  • $[[1], [1], [2]]$
  • $[[1, 1], [2]]$
  • $[[1, 1, 2]]$
翻译中…

Division $[[1], [1, 2]]$ is not possible because two distinct integers appear exactly once in the second segment $[1, 2]$.

翻译中…

样例

Input #1
3 1
1 1 2
Output #1
3
InputCopy OutputCopy
Input #2
5 2
1 1 2 1 3
Output #2
14
InputCopy OutputCopy
Input #3
5 5
1 2 3 4 5
Output #3
16
InputCopy OutputCopy
题目信息
题号
1129D
时间限制
3 s
内存限制
256 MB
标签
数据结构
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。