luogu#P8559. 寻宝(Treasure)
寻宝(Treasure)
Problem Description
Ling is going treasure hunting on a grid of size rows and 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 walls. Among all possible maps, in how many cases can you find exactly 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 .”
With no choice, Ling asks you to help compute the answer.
Input Format
A single line with three positive integers .
Output Format
A single line with one integer, the answer modulo .
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 , with obstacles. There are cases where you can find exactly 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 cases where, starting from the entrance, you can reach exactly empty cells (and thus obtain treasures).
So the answer is .
[Constraints]
This problem uses bundled testdata.
Subtask 1 (11 pts): .
Subtask 2 (19 pts): .
Subtask 3 (31 pts): .
Subtask 4 (39 pts): no additional constraints.
For of the testdata, , , and .
[Note]
This is an OI problem, not a proof problem.
Translated by ChatGPT 5