QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 难度: [显示] 可 Hack ✓
统计

小青鱼正在探索一个雨的世界!这个二维世界被表示为一个 $N \times M$ 的网格。我们将第 $i$ 行第 $j$ 列的单元格记为 $(i, j)$,其中 $1 \le i \le N$ 且 $1 \le j \le M$。

在这个世界中,一只神奇的猫控制着降雨。降雨过程持续 $S+1$ 秒,编号从 $1$ 到 $S+1$。在开始时(时间 $0$,即第一秒之前),没有任何单元格包含水滴。

在每一秒 $i$($1 \le i \le S+1$),会发生以下过程:

  1. 降雨:对于每个当前不包含水滴的单元格,猫会独立且随机地决定是否在该单元格中产生一个新的水滴。
  2. 移动($S+1$ 时刻除外):如果 $i \le S$,所有现有的水滴会由于重力和风的作用同时移动。位于单元格 $(x, y)$ 的水滴会移动到单元格 $(x+1, y+d_i)$。
  3. 消失:任何移动到 $N \times M$ 网格边界之外的水滴都会永久消失。

你的任务是计算不同可能的降雨方案总数。如果存在至少一个单元格 $(i, j)$ 和一个时间 $t$($1 \le t \le S+1$),使得在一种方案中该单元格在时刻 $t$ 产生了一个水滴,而在另一种方案中没有,则认为这两个方案不同。

由于方案总数可能非常大,请输出结果对 $998\,244\,353$ 取模后的值。

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$ ($T \ge 1$),表示测试数据的组数。对于每组测试数据:

第一行包含三个整数 $N, M, S$ ($1 \le N, M, S \le 5 \times 10^5$)。 下一行包含 $S$ 个整数:$d_1, d_2, \dots, d_S$ ($-10^9 \le d_i \le 10^9$)。

保证所有测试数据的 $S$ 之和不超过 $5 \times 10^5$。

输出格式

对于每组测试数据:

输出一行,包含一个整数,表示答案对 $998\,244\,353$ 取模后的结果。

样例

样例输入 1

3
2 2 1
1
3 3 5
1 0 0 0 -1
9 10 7
1 4 -2 -8 5 -7 142857

样例输出 1

192
536867776
736446321

Figure 1. 小青鱼探索雨的世界

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.