Universal Cup Judging System

Universal Cup

حد الوقت: 3.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

題目描述

有一個由 $N \times N$ 個格仔組成嘅正方形網格。由上至下第 $i$ 行、由左至右第 $j$ 列嘅格仔記作 $(i, j)$。格仔 $(i, j)$ 上面寫住一個滿足 $1 \le A_{i,j} \le (N - K)^2$ 嘅整數 $A_{i,j}$。你將會按順序執行以下操作:

  • 喺 $N$ 行入面揀 $K$ 行,並刪走所揀行入面嘅格仔。
  • 喺 $N$ 列入面揀 $K$ 列,並刪走所揀列入面嘅格仔。

視乎揀選行列嘅方式,剩低嘅 $(N - K)^2$ 個格仔上面寫住嘅整數可能會互不相同。請計算滿足呢個條件嘅刪除行列揀選方案數,對 $998244353$ 取模。

當且僅當存在至少一行或一列喺其中一種方案入面被揀中,而喺另一種方案入面冇被揀中時,兩種揀選方案先至算係唔同。

輸入格式

輸入由標準輸入按以下格式給出:

N K
A_{1,1} A_{1,2} ... A_{1,N}
:
A_{N,1} A_{N,2} ... A_{N,N}

數據範圍

  • $1 \le K < N \le 1000$
  • $1 \le K \le 5$
  • $1 \le A_{i,j} \le (N - K)^2$ ($1 \le i \le N, 1 \le j \le N$)
  • 輸入嘅所有數值都係整數。

輸出格式

請輸出滿足條件嘅行列揀選方案數,對 $998244353$ 取模。

範例

範例輸入1

3 1
3 1 4
1 4 2
2 3 1

範例輸出1

6

範例輸入2

3 2
1 1 1
1 1 1
1 1 1

範例輸出2

9

範例輸入3

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

範例輸出3

10

範例解釋

範例 1 解釋

喺以下 $6$ 種揀選方案入面,剩低嘅 $(N - K)^2$ 個格仔上面寫住嘅整數剛好包含 $1, 2, 3, 4$ 各一次,因此滿足條件:

  • 刪走由上至下第 $1$ 行同由左至右第 $1$ 列
  • 刪走由上至下第 $1$ 行同由左至右第 $2$ 列
  • 刪走由上至下第 $1$ 行同由左至右第 $3$ 列
  • 刪走由上至下第 $2$ 行同由左至右第 $3$ 列
  • 刪走由上至下第 $3$ 行同由左至右第 $2$ 列
  • 刪走由上至下第 $3$ 行同由左至右第 $3$ 列

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1494EditorialOpen题解jianglyView
#1346EditorialOpen题解MilmonView

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.