QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 512 MB Total points: 100

#1929. U 群把妹王

Statistics

$\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]$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.