QOJ.ac

QOJ

Limite de temps : 5 s Limite de mémoire : 512 MB Points totaux : 100

#1929. U 群把妹王

Statistiques

$\bullet$ 小天使 忆艾 $\bullet$:哇哦,你一個人在 UOJ 群找什麼呢?

「1. 找多項式」

「2. 找小天使」

有 $n\times m$ 個格子,每個格子進行染色,可以選擇 $k$ 種顏色之一。對於集合 $S, T$,你需要計數有多少種格子的染色方案,滿足:

  • 對於每一行的圖案拿出來,和它相同的圖案總共有 $r$ 行(含自身),則 $r\in S$。
  • 對於每一列的圖案拿出來,和它相同的圖案總共有 $c$ 列(含自身),則 $c\in T$。

答案對 $P = 998244353$ 取模。

為了讓這道題看起來程式碼比較健康,保證 $1\in S \cap T$。

輸入格式

第一行輸入五個正整數,分別為 $n, m, k, a, b$。

接下來一行輸入 $a$ 個正整數,從小到大表示集合 $S$ 中的數,保證數不重複。

接下來一行輸入 $b$ 個正整數,從小到大表示集合 $T$ 中的數,保證數不重複。

輸出格式

輸出一個整數,表示滿足要求的染色數同餘 $P$。

範例

範例 1 輸入

2 2 2 1 1
1
1

範例 1 輸出

10

說明 1

即任意兩行顏色不同,任意兩列顏色不同。

$2^4 = 16$ 種染色方案中,有以下 $6$ 種是不合法的:

11 00 01 10 00 11
00 11 01 10 00 11

範例 2 輸入

49 50 666 5 4
1 2 6 9 19
1 2 3 5

範例 2 輸出

132764272

範例 3 輸入

10492 11451 1122334 5 5
1 2 600 9700 10492
1 2 301 3131 4921

範例 3 輸出

208881352

子任務

對於 $10\%$ 的資料,保證 $n, m\le 50$。

對於 $40\%$ 的資料,保證 $n, m\le 3000$。

對於另外 $10\%$ 的資料,保證 $S = T = \{1\}$。

對於 $100\%$ 的資料,保證 $1\le n, m\le 10^5, 1\le k\le P - 1, 1\le a, b\le5, 1\in S \cap T, S \subseteq [1, n], T \subseteq [1, m]$。

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.