QOJ.ac

QOJ

Limite de temps : 5.0 s Limite de mémoire : 1024 MB Points totaux : 100

#9444. 又是排列问题

Statistiques

给定 $M$ 个 $(1, 2, \dots, N)$ 的排列。第 $i$ 个排列为 $P_i = (P_{i,1}, P_{i,2}, \dots, P_{i,N})$。 你有一个序列 $Q = (1, 2, \dots, N)$。你可以执行零次或多次以下操作: * 选择一个满足 $1 \le i \le M$ 的整数 $i$,并将 $Q$ 更新为 $(Q_{P_{i,1}}, Q_{P_{i,2}}, \dots, Q_{P_{i,N}})$。

求出在执行任意次数操作后,所有可能得到的序列 $Q$ 的逆序对数量之和。输出结果对 $998244353$ 取模。

数据范围

  • $1 \le N \le 30$
  • $1 \le M \le 30$
  • $P_i = (P_{i,1}, P_{i,2}, \dots, P_{i,N})$ 是 $(1, 2, \dots, N)$ 的一个排列。

输入格式

输入通过标准输入按以下格式给出:

$N \ M$ $P_{1,1} \ P_{1,2} \ \dots \ P_{1,N}$ $P_{2,1} \ P_{2,2} \ \dots \ P_{2,N}$ $\vdots$ $P_{M,1} \ P_{M,2} \ \dots \ P_{M,N}$

输出格式

输出答案。

样例

样例输入 1

3 2
1 2 3
2 3 1

样例输出 1

4

样例输入 2

5 2
3 4 5 1 2
1 5 4 3 2

样例输出 2

50

样例输入 3

30 12
1 2 9 4 5 6 <...> 26 3 28 29 30
(download in the attchments)

样例输出 3

701414999

说明

对于第一个样例: 共有三种可能的序列 $Q$:$(1, 2, 3)$,$(2, 3, 1)$ 和 $(3, 1, 2)$。它们的逆序对数量分别为 $0$,$2$ 和 $2$,因此答案为 $0 + 2 + 2 = 4$。

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.