#P4111. [HEOI2015] 小 Z 的房间

    ID: 3047 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015各省省选河北生成树素数判断,质数,筛法高斯消元

[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 n×mn\times m 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 10910^9.

Input Format

The first line contains two integers n,mn,m.

Then follow nn lines, each containing mm characters . or *, where . denotes a room and * denotes a pillar.

Output Format

Output a single integer, the number of valid plans modulo 10910^9.

2 2
..
..

4

2 2
*.
.*

0

Hint

Constraints

  • For 20%20\% of the testdata, n,m3n,m \le 3.
  • For 50%50\% of the testdata, n,m5n,m \le 5.
  • For 40%40\% of the testdata, min(n,m)3\min(n,m) \le 3.
  • For 30%30\% of the testdata, there are no pillars.
  • For 100%100\% of the testdata, 1n,m91 \le n,m \le 9.

Translated by ChatGPT 5