#P4111. [HEOI2015] 小 Z 的房间
[HEOI2015] 小 Z 的房间
Description
You suddenly have a big house, which contains some rooms. In fact, your house can be regarded as a grid rectangle with cells, where each cell is either a room or a pillar. Initially, there is a wall between every pair of adjacent cells.
You want to knock down some walls between adjacent rooms so that all rooms become mutually reachable. During this process, you must not break through the house boundary, nor open a pillar (as well as the walls next to a pillar). Meanwhile, you do not want it to be hard to catch thieves, so you require that there be exactly one path between any two rooms. Now, count how many feasible plans there are; output the answer modulo .
Input Format
The first line contains two integers .
Then follow lines, each containing characters . or *, where . denotes a room and * denotes a pillar.
Output Format
Output a single integer, the number of valid plans modulo .
2 2
..
..
4
2 2
*.
.*
0
Hint
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, there are no pillars.
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号