Codeforces Round 723 (Div. 2)
E
Oolimry and Suffix Array
Codeforces
2400
原题
← DF →
翻译中…

Once upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array.

翻译中…

More formally, given a suffix array of length $n$ and having an alphabet size $k$, count the number of strings that produce such a suffix array.

翻译中…

Let $s$ be a string of length $n$. Then the $i$-th suffix of $s$ is the substring $s[i \ldots n-1]$. A suffix array is the array of integers that represent the starting indexes of all the suffixes of a given string, after the suffixes are sorted in the lexicographic order. For example, the suffix array of oolimry is $[3,2,4,1,0,5,6]$ as the array of sorted suffixes is $[\texttt{imry},\texttt{limry},\texttt{mry},\texttt{olimry},\texttt{oolimry},\texttt{ry},\texttt{y}]$.

翻译中…

A string $x$ is lexicographically smaller than string $y$, if either $x$ is a prefix of $y$ (and $x\neq y$), or there exists such $i$ that $x_i \lt y_i$, and for any $1\leq j \lt i$ , $x_j = y_j$.

翻译中…

Input

翻译中…

The first line contain 2 integers $n$ and $k$ ($1 \leq n \leq 200000,1 \leq k \leq 200000$) — the length of the suffix array and the alphabet size respectively.

翻译中…

The second line contains $n$ integers $s_0, s_1, s_2, \ldots, s_{n-1}$ ($0 \leq s_i \leq n-1$) where $s_i$ is the $i$-th element of the suffix array i.e. the starting position of the $i$-th lexicographically smallest suffix. It is guaranteed that for all $0 \leq i \lt j \leq n-1$, $s_i \neq s_j$.

翻译中…

Output

翻译中…

Print how many strings produce such a suffix array. Since the number can be very large, print the answer modulo $998244353$.

翻译中…

Note

翻译中…

In the first test case, "abb" is the only possible solution.

翻译中…

In the second test case, it can be easily shown no possible strings exist as all the letters have to be equal.

翻译中…

In the fourth test case, one possible string is "ddbacef".

翻译中…

Please remember to print your answers modulo $998244353$.

翻译中…

样例

Input #1
3 2
0 2 1
Output #1
1
InputCopy OutputCopy
Input #2
5 1
0 1 2 3 4
Output #2
0
InputCopy OutputCopy
Input #3
6 200000
0 1 2 3 4 5
Output #3
822243495
InputCopy OutputCopy
Input #4
7 6
3 2 4 1 0 5 6
Output #4
36
InputCopy OutputCopy
题目信息
题号
1526E
时间限制
1 s
内存限制
256 MB
标签
组合数学
构造
数学

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