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

문제

Farmer John's pasture can be regarded as a large 2D grid of square "cells" (picture a huge chessboard) labeled by the ordered pairs (i,j)(i,j) for each 1iN1\le i\le N, 1jN1\le j\le N (1N1501\le N\le 150). Some of the cells contain grass.

A nonempty subset of grid cells is called "balanced" if the following conditions hold:

All cells in the subset contain grass.The subset is 4-connected. In other words, there exists a path from any cell in the subset to any other cell in the subset such that every two consecutive cells of the path are horizontally or vertically adjacent.If cells (x1,y)(x_1,y) and (x2,y)(x_2,y) (x1x2x_1\le x_2) are part of the subset, then all cells (x,y)(x,y) with x1xx2x_1\le x\le x_2 are also part of the subset.If cells (x,y1)(x,y_1) and (x,y2)(x,y_2) (y1y2y_1\le y_2) are part of the subset, then all cells (x,y)(x,y) with y1yy2y_1\le y\le y_2 are also part of the subset.

Count the number of balanced subsets modulo 109+710^9+7.

입력

The first line contains NN.

The next NN lines each contain a string of NN characters. The jj-th character of the ii-th line from the top is equal to G if the cell at (i,j)(i,j) contains grass, or . otherwise.

출력

The number of balanced subsets modulo 109+710^9+7.

예제 입력 1

2
GG
GG

예제 출력 1

13

예제 입력 2

4
GGGG
GGGG
GG.G
GGGG

예제 출력 2

642

점수

Test cases 1-4 satisfy N4N\le 4.Test cases 5-10 satisfy N20N\le 20.Test cases 11-20 satisfy no additional constraints.

코드 제출

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

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