QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 1024 MB Puntuación total: 100

#3090. 逆问题

Estadísticas

给定一个整数 $N$ 和一个长度为 $M$ 的整数序列 $X$。请计算满足以下条件的 $(1, 2, \dots, N)$ 的排列 $P = (P_1, P_2, \dots, P_N)$ 的数量,结果对 $998244353$ 取模:

  • $P$ 的长度为 $M$ 的字典序最小子序列与 $X$ 相等。

输入格式

第一行包含整数 $N$ ($1 \le N \le 250000$) 和 $M$ ($1 \le M \le N$)。

第二行包含整数 $X_1, X_2, \dots, X_M$ ($1 \le X_i \le N, X_i \neq X_j$ 对于所有 $i \neq j$)。

输出格式

输出答案。

样例

样例输入 1

3 2
1 2

样例输出 1

3

样例输入 2

10 5
2 7 8 3 6

样例输出 2

0

样例输入 3

5 5
1 2 3 4 5

样例输出 3

1

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#192EditorialOpen题解jiangly2025-12-13 00:02:11View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.