P27490 [AtCoder] Determinant?
提高
题目描述

Problem Description

Given $ N $ $K \times K$ matrices $A_1, \ldots, A_N$ with integer components. The $ (i, j) $ component of $ A_h $ is $ A_{h,i,j} $ ($1 \le h \le N$, $1 \le i \le K$, $1 \le j \le K$).

Let $\mathfrak{S}_N$ be the symmetric group of order $ N $. Compute the components of the $K \times K$ matrix $\sum_{\sigma \in \mathfrak{S}_N} \operatorname{sgn}(\sigma) A_{\sigma(1)} \cdots A_{\sigma(N)}$ modulo $ 998244353 $ (between $ 0 $ and $ 998244353 $ exclusive).

(In other words, for each of the $ N! $ permutations of $A_1, \ldots, A_N$, compute the matrix product in that order multiplied by the sign of the permutation and sum them up. Then, compute each component modulo $ 998244353 $.)

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ A_{1,1,1} $ $\cdots$ $ A_{1,1,K} $ $\vdots$ $ A_{1,K,1} $ $\cdots$ $ A_{1,K,K} $ $\vdots$ $\vdots$ $\vdots$ $ A_{N,1,1} $ $\cdots$ $ A_{N,1,K} $ $\vdots$ $ A_{N,K,1} $ $\cdots$ $ A_{N,K,K} $

Output Format

Let $ b_{i,j} $ be the remainder of the $ (i, j) $ component of the resulting sum when divided by $ 998244353 $ ($1 \le i \le K$, $1 \le j \le K$). Output in the following format:

$ b_{1,1} $ $\cdots$ $ b_{1,K} $ $\vdots$ $ b_{K,1} $ $\cdots$ $ b_{K,K} $

Sample Input and Output

Sample Input #1

2 3
2 7 1
8 2 8
1 8 2
8 4 5
9 0 4
5 2 3

Sample Output #1

31 998244259 998244344
100 998244306 55
61 998244298 16

Sample Input #2

3 2
30 10
40 10
50 90
20 60
50 30
50 80

Sample Output #2

155000 122000
67000 364000

Notes/Hints

Constraints

  • $1 \le N \le 32$.
  • $1 \le K \le 8$.
  • $0 \le A_{h,i,j} < 998244353$ ($1 \le h \le N$, $1 \le i \le K$, $1 \le j \le K$).

Sample Explanation 1

$A_0 A_1 - A_1 A_0 = \begin{bmatrix} 31 & -94 & -9 \\ 100 & -47 & 55 \\ 61 & -55 & 16 \end{bmatrix}$.

Sample Explanation 2

$A_0 A_1 A_2 - A_0 A_2 A_1 - A_1 A_0 A_2 + A_1 A_2 A_0 + A_2 A_0 A_1 - A_2 A_1 A_0 = \begin{bmatrix} 155000 & 122000 \\ 67000 & 364000 \end{bmatrix}$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 3 2 7 1 8 2 8 1 8 2 8 4 5 9 0 4 5 2 3
样例输出
31 998244259 998244344 100 998244306 55 61 998244298 16