第 228 场 AtCoder Regular Contest++
A
交换行与列
Row and Col swap
AtCoder
⌀ 2751
原题
←B →

交换行与列AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

You are given permutations $P=(P_1,P_2,\dots,P_N)$ and $Q=(Q_1,Q_2,\dots,Q_N)$ of $(1,2,\dots,N)$.

给定 $(1,2,\dots,N)$ 的两个排列 $P=(P_1,P_2,\dots,P_N)$ 和 $Q=(Q_1,Q_2,\dots,Q_N)$。AI (CI翻译)

For $P$ and $Q$, you repeat the following $M$ times: choose and perform one of the operations below.

对于 $P$ 和 $Q$,重复进行以下操作 $M$ 次:选择并执行下列操作之一。AI (CI翻译)

  • Choose integers $i$ and $j$ satisfying $1 \le i < j \le N$, and swap $P_i$ and $P_j$.
  • Choose integers $i$ and $j$ satisfying $1 \le i < j \le N$, and swap $Q_i$ and $Q_j$.
  • Choose an integer $i$ satisfying $1 \le i \le N$, and swap $P_i$ and $Q_i$.
  • 选择满足 $1 \le i < j \le N$ 的整数 $i$ 和 $j$,交换 $P_i$ 和 $P_j$。
  • 选择满足 $1 \le i < j \le N$ 的整数 $i$ 和 $j$,交换 $Q_i$ 和 $Q_j$。
  • 选择满足 $1 \le i \le N$ 的整数 $i$,交换 $P_i$ 和 $Q_i$。
AI (CI翻译)

Find the number, modulo $998244353$, of sequences of operations such that both $P$ and $Q$ are permutations of $(1,2,\dots,N)$ after the $M$ operations.

求操作 $M$ 次后,$P$ 和 $Q$ 都是 $(1,2,\dots,N)$ 的排列的操作序列数量。答案对 $998244353$ 取模。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \le N,M \le 500$
  • $P$ and $Q$ are permutations of $(1,2,\dots,N)$.
  • All input values are integers.
  • $1 \le N,M \le 500$
  • $P$ 和 $Q$ 都是 $(1,2,\dots,N)$ 的排列。
  • 输入的所有数值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

N M
P_1\ P_2\ \dots\ P_N
Q_1\ Q_2\ \dots\ Q_N

N M
P_1\ P_2\ \dots\ P_N
Q_1\ Q_2\ \dots\ Q_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the answer.

输出答案。AI (CI翻译)

样例

Input #1
3 1
1 2 3
1 3 2
Output #1
7
For example, the following sequence of operations satisfies the condition. - Choose $i = 1$ in an operation of the third kind to swap $P_1$ and $Q_1$. Now $P=(1,2,3)$ and $Q=(1,3,2)$. Any sequence of operations composed of exactly one of the following seven operations satisfies the condition: the three operations that swap two elements of $P$, the three operations that swap two elements of $Q$, and the operation described above that swaps $P_1$ and $Q_1$.
Input #2
3 2
1 2 3
1 3 2
Output #2
53
Input #3
8 15
6 4 8 3 2 7 1 5
1 6 4 5 7 2 8 3
Output #3
571380540
题目信息
题号
arc228_a
时间限制
5 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。