NC222394. [USACOOPEN2021P]BalancedSubsets
描述
A nonempty subset of grid cells is called "balanced" if the following conditions hold:
Count the number of balanced subsets modulo 109+7.
输入描述
The first line contains N.The next N lines each contain a string of N characters. The j-th character of the i-th line from the top is equal to G if the cell at (i,j) contains grass, or . otherwise.
输出描述
The number of balanced subsets modulo 109+7.
示例1
输入:
2 GG GG
输出:
13
说明:
For this test case, all 4-connected subsets are balanced.
G. .G .. .. GG .G .. G. GG .G G. GG GG .., .., G., .G, .., .G, GG, G., G., GG, GG, .G, GG
示例2
输入:
4 GGGG GGGG GG.G GGGG
输出:
642
说明:
Here is an example of a subset that satisfies the second condition (it is 4-connected) but does not satisfy the third condition:
GG.. .G.. GG.. ....