luogu#P8559. 寻宝(Treasure)

    ID: 7231 远端评测题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>数学递推莫队洛谷原创O2优化生成函数高斯消元

寻宝(Treasure)

Problem Description

Ling is going treasure hunting on a grid of size 22 rows and n+1n+1 columns.
With such a chance, she will not miss any treasure she can possibly get.

Each cell has one of two states: empty or wall.

Empty cells can be passed through freely. Also, except for the bottom cell of the first column, every empty cell contains a treasure. The first column is guaranteed to be empty, and it is also the entrance of the map.

Walls cannot be passed through.

Note that each move can only go to an adjacent cell, and the boundary of the map cannot be crossed either.

Ling still does not know the exact layout of the map. While she is thinking about a strategy, Mio says: “I know the map has exactly kk walls. Among all possible maps, in how many cases can you find exactly mm treasures?”
“So what if I don’t answer?” Ling only wants to dig for treasure, and replies lightly.
“Huh? Then I won’t tell you about several treasure locations~” Mio looks serious. “But I won’t make it too hard for you. You only need to output the answer modulo 998244353998244353.”

With no choice, Ling asks you to help compute the answer.

Input Format

A single line with three positive integers n,k,mn, k, m.

Output Format

A single line with one integer, the answer modulo 998244353998244353.

3 3 2
4
10 9 11

776
10 8 7
6776
233 123 114
22504357

Hint

[Explanation for Sample 1]

The map size is 2×(3+1)2\times(3+1), with 33 obstacles. There are 44 cases where you can find exactly 22 treasures, as shown below:

In the figure, the green part is the entrance, gray cells are walls, and white cells are empty cells with treasure.
You can see that there are exactly 44 cases where, starting from the entrance, you can reach exactly 22 empty cells (and thus obtain 22 treasures).

So the answer is 44.

[Constraints]

This problem uses bundled testdata.

Subtask 1 (11 pts): n12n\leq 12.
Subtask 2 (19 pts): n1000n\leq 1000.
Subtask 3 (31 pts): n5×104n \leq 5\times 10^4.
Subtask 4 (39 pts): no additional constraints.

For 100%100\% of the testdata, 2n3×1062\le n \le 3\times 10^6, m,k2m, k\geq 2, and m+k2nm+k\leq 2n.

[Note]
This is an OI problem, not a proof problem.

Translated by ChatGPT 5