408881: GYM103371 I Organizing Colored Sheets

Memory Limit:1024 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Organizing Colored Sheetstime limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

There is a large grid of size $$$n \times m$$$, where each grid cell is either colored or uncolored.

To make some artwork on the grid, Hyunuk wants to put some sheets of colored paper in some of the uncolored cells. Hyunuk selects two integers $$$w, h$$$ where $$$1 \le w \le m, 1 \le h \le n$$$. Then, Hyunuk covers the grid with sheets of colored paper of width $$$w$$$ and height $$$h$$$, satisfying the following conditions.

  • The colored paper should exactly cover the grid cells, and not go out of the grid.
  • The colored paper cannot be rotated.
  • A cell may be covered with more than one sheet of colored paper.
  • Every uncolored cell must be covered with at least one sheet of colored paper.
  • No colored cell can be covered with any colored paper.

Depending on the selection of width and height, Hyunuk may fail to cover the grid satisfying the above conditions. Please compute the number of possible sheet sizes that can cover the grid satisfying all the above conditions.

Input

The first line contains two integers $$$n$$$ and $$$m \, (1 \le n, m \le 3\,000)$$$.

The next $$$n$$$ lines each contain a length $$$m$$$ string denoting the state of the grid. . denotes an uncolored cell, and # denotes a colored cell.

There is at least one uncolored cell in the grid.

Output

Output the number of possible sheet sizes that can cover the grid satisfying all the above conditions.

ExamplesInput
3 3
..#
...
#..
Output
4
Input
8 9
.........
.........
.........
...#.....
.....#...
....#....
.........
.........
Output
4
Input
9 9
######...
######...
######...
#........
#.....###
#.....###
#####....
#####....
#####....
Output
9
Input
5 5
.....
....#
...##
..###
.####
Output
1
Note

In the first example, the following four colored paper satisfy the conditions: $$$1 \times 1$$$, $$$1 \times 2$$$, $$$2 \times 1$$$, and $$$2 \times 2$$$. Since the colored paper can not be rotated, $$$1 \times 2$$$ and $$$2 \times 1$$$ are considered different sizes.

加入题单

上一题 下一题 算法标签: