408071: GYM102978 I Inverse Problem
Memory Limit:1024 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
I. Inverse Problemtime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output
You are given an integer $$$N$$$ and an integer sequence $$$X$$$ of length $$$M$$$. Count, modulo $$$998244353$$$, the number of permutations $$$P = (P_1,P_2,\ldots,P_N)$$$ of $$$(1,2,\ldots,N)$$$ that satisfy the following condition:
- The lexicographically smallest subsequence of $$$P$$$ of length $$$M$$$ coincides with $$$X$$$.
The first line contains integers $$$N$$$ ($$$1 \leq N \leq 250000$$$) and $$$M$$$ ($$$1 \leq M \leq N$$$).
The second line contains integers $$$X_1,X_2,\ldots,X_M$$$ ($$$1 \leq X_i \leq N$$$, $$$X_i \neq X_j$$$ for all $$$i \neq j$$$).
OutputPrint the answer.
ExamplesInput3 2 1 2Output
3Input
10 5 2 7 8 3 6Output
0Input
5 5 1 2 3 4 5Output
1