码迷,mamicode.com
首页 > 其他好文 > 详细

Timus Online Judge1627--- Join

时间:2015-01-30 09:16:22      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

1627. Join

Time limit: 4.0 second
Memory limit: 64 MB
Businessman Petya recently bought a new house. This house has one floor withn ×m square rooms, placed in rectangular lattice. Some rooms are pantries and the other ones are bedrooms. Now he wants to join all bedrooms with doors in such a way that there will be exactly one way between any pair of them. He can make doors only between neighbouring bedrooms (i.e. bedrooms having a common wall). Now he wants to count the number of different ways he can do it.

Input

First line contains two integers n and m (1 ≤ n, m ≤ 9) — the number of lines and columns in the lattice. Nextn lines contain exactlym characters representing house map, where "." means bedroom and "*" means pantry. It is guaranteed that there is at least one bedroom in the house.

Output

Output the number of ways to join bedrooms modulo 109.

Samples

input output
2 2
..
..
4
2 2
*.
.*
0
Problem Source: SPbSU ITMO contest. Petrozavodsk training camp. Winter 2008.

Timus Online Judge1627--- Join

标签:

原文地址:http://blog.csdn.net/guard_mine/article/details/43274743

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!