QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#14412. 让我们来度量排列

Estadísticas

考虑一个由整数 $1, 2, \dots, n$ 组成的排列 $p$。它与排列 $(1, 2, \dots, n)$ 有多接近?

Lisa 用 $p$ 中的逆序对数量来衡量:即满足 $i < j$ 且 $p_i > p_j$ 的二元组 $(i, j)$ 的数量。

另一方面,Leo 使用度量值 $\frac{1}{2} \sum_{i=1}^n |p_i - i|$。

给定一个由 $1$ 到 $n$ 之间的 $k$ 个互不相同的整数组成的序列 $a = (a_1, a_2, \dots, a_k)$,共有 $(n - k)!$ 个长度为 $n$ 且以 $a$ 为前缀的排列。

求这些排列中,Lisa 的度量值与 Leo 的度量值相等的排列数量,并将结果模 $998\,244\,353$ 后输出。

输入格式

输入的第一行包含两个整数 $n$ 和 $k$($1 \le n \le 2 \cdot 10^5$,$0 \le k \le n$)。

如果 $k$ 大于 $0$,第二行包含 $k$ 个两两不同的整数 $a_i$,表示排列的前缀($1 \le a_i \le n$,且对于 $i \ne j$ 有 $a_i \ne a_j$)。

输出格式

输出一个整数:满足条件的排列数量模 $998\,244\,353$ 的值。

样例

输入样例 1

5 3
2 3 5

输出样例 1

1

输入样例 2

10 10
3 1 4 5 9 2 6 8 7 10

输出样例 2

0

输入样例 3

6 0

输出样例 3

132

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.