Codeforces Round 202 (Div. 1)
D
Turtles
Codeforces
2500
原题
← CE →
翻译中…

You've got a table of size $*n* × *m*$. We'll consider the table rows numbered from top to bottom 1 through $*n*$, and the columns numbered from left to right 1 through $*m*$. Then we'll denote the cell in row $*x*$ and column $*y*$ as $(*x*, *y*)$.

翻译中…

Initially cell $(1, 1)$ contains two similar turtles. Both turtles want to get to cell $(*n*, *m*)$. Some cells of the table have obstacles but it is guaranteed that there aren't any obstacles in the upper left and lower right corner. A turtle (one or the other) can go from cell $(*x*, *y*)$ to one of two cells $(*x* + 1, *y*)$ and $(*x*, *y* + 1)$, as long as the required cell doesn't contain an obstacle. The turtles have had an argument so they don't want to have any chance of meeting each other along the way. Help them find the number of ways in which they can go from cell $(1, 1)$ to cell $(*n*, *m*)$.

翻译中…

More formally, find the number of pairs of non-intersecting ways from cell $(1, 1)$ to cell $(*n*, *m*)$ modulo $1000000007$ $(10^{9} + 7)$. Two ways are called non-intersecting if they have exactly two common points — the starting point and the final point.

翻译中…

Input

翻译中…

The first line contains two integers $*n*, *m*$ $(2 ≤ *n*, *m* ≤ 3000)$. Each of the following $*n*$ lines contains $*m*$ characters describing the table. The empty cells are marked by characters ".", the cells with obstacles are marked by "#".

翻译中…

It is guaranteed that the upper left and the lower right cells are empty.

翻译中…

Output

翻译中…

In a single line print a single integer — the number of pairs of non-intersecting paths from cell $(1, 1)$ to cell $(*n*, *m*)$ modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

样例

Input #1
4 5
.....
.###.
.###.
.....
Output #1
1
InputCopy OutputCopy
Input #2
2 3
...
...
Output #2
1
InputCopy OutputCopy
题目信息
题号
348D
时间限制
2 s
内存限制
256 MB
标签
动态规划
矩阵

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。