#P2595. [ZJOI2009] 多米诺骨牌

    ID: 1608 远端评测题 2000ms 125MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划,dp2009各省省选浙江状态压缩,状压容斥

[ZJOI2009] 多米诺骨牌

Description

There is an n×mn \times m rectangular grid with some cells blocked by obstacles. You need to place some 1×21 \times 2 or 2×12 \times 1 dominoes on this grid so that any two dominoes do not overlap, and no domino covers an obstacle. Moreover, for every pair of adjacent rows, there must be at least one domino crossing them; similarly, for every pair of adjacent columns, there must be at least one domino crossing them. Find the number of different placement methods. Note that you do not need to cover all unobstructed cells.

Input Format

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

The next nn lines each contain mm characters describing the grid. Character x means the cell has an obstacle, and character . means the cell is empty.

Output Format

Output a single integer: the number of different placements modulo 1990101319\,901\,013.

3 3
...
...
...
2

Hint

Sample explanation:

Two valid placements are:

112 411
4.2 4.2
433 332

Note that the digits are only used to distinguish dominoes; different labelings do not represent different solutions.

Constraints:

  • For 40%40\% of the testdata, n,m8n, m \leq 8.
  • For 90%90\% of the testdata, n,m14n, m \leq 14.
  • For 100%100\% of the testdata, 1n,m151 \leq n, m \leq 15.

Translated by ChatGPT 5