#459
Unrated
Cave Paintings
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie has become an artist and is creating paintings of caves! Her current work in progress is a grid of height NN such that each row of the grid contains exactly MM squares (1N,M10001\le N,M\le 1000). Each square is either empty, filled with rock, or filled with water. Bessie has already painted the squares containing rock, including the entire border of the painting. She now wants to fill some empty squares with water such that if the painting were real, there would be no net motion of water. Define the height of a square in the ii-th row from the top to be N+1iN+1-i. Bessie wants her painting to satisfy the following constraint:

Suppose that square aa is filled with water. Then if there exists a path from aa to square bb using only empty or water squares that are not higher than aa such that every two adjacent squares on the path share a side, then bb is also filled with water.

Find the number of different paintings Bessie can make modulo 109+710^9+7. Bessie may fill any number of empty squares with water, including none or all.

SCORING: Test cases 1-5 satisfy N,M10.N,M\le 10.Test cases 6-15 satisfy no additional constraints.

입력

The first line contains two space-separated integers NN and MM.

The next NN lines of input each contain MM characters. Each character is either '.' or '#', representing an empty square and a square filled with rock, respectively. The first and last row and first and last column only contain '#'.

출력

A single integer: the number of paintings satisfying the constraint modulo 109+710^9+7.

예제 입력 1

4 9
#########
#...#...#
#.#...#.#
#########

예제 출력 1

9
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.