#ABC475F. 矩形涂黑 / Rectangle Filling
矩形涂黑 / Rectangle Filling
Problem Statement
There is a grid with rows and columns. Let the cell at the -th row from the top and -th column from the left be denoted as cell .
Each cell of the grid is painted white or black: cell is white if the -th character of is ., and black if it is #.
You can perform the following operation at most once.
- Choose a rectangular region, and paint all cells within that region black. More formally, choose integers satisfying and , and paint cell black for every pair of integers satisfying and .
Find the number of possible states of the grid that can be obtained. Here, two states of the grid are considered different if there exists a pair of integers satisfying and such that cell is painted white in one state and painted black in the other state.
Constraints
- and are integers.
- is a string of length consisting of
.and#.
Input
The input is given from Standard Input in the following format:
Output
Output the answer.
2 3
#..
.##
7
The possible states of the grid obtainable by performing the operation at most once are the following seven:
#.. ##. #.# ### #.. ##. ###
.## .## .## .## ### ### ###
4 1
#
#
#
#
1
5 5
..##.
..#.#
.##.#
....#
##.##
96
- Source: AtCoder ABC 475 F
相关
在下列比赛中: