Bayan 2015 Contest Warm Up
C
Kamal-ol-molk's Painting
Codeforces
2100
原题
← BD →
翻译中…

Rumors say that one of Kamal-ol-molk's paintings has been altered. A rectangular brush has been moved right and down on the painting.

翻译中…

Consider the painting as a $*n* × *m*$ rectangular grid. At the beginning an $*x* × *y*$ rectangular brush is placed somewhere in the frame, with edges parallel to the frame, ($1 ≤ *x* ≤ *n*, 1 ≤ *y* ≤ *m*$). Then the brush is moved several times. Each time the brush is moved one unit right or down. The brush has been strictly inside the frame during the painting. The brush alters every cell it has covered at some moment.

翻译中…

You have found one of the old Kamal-ol-molk's paintings. You want to know if it's possible that it has been altered in described manner. If yes, you also want to know minimum possible area of the brush.

翻译中…

Input

翻译中…

The first line of input contains two integers $*n*$ and $*m*$, ($1 ≤ *n*, *m* ≤ 1000$), denoting the height and width of the painting.

翻译中…

The next $*n*$ lines contain the painting. Each line has $*m*$ characters. Character 'X' denotes an altered cell, otherwise it's showed by '.'. There will be at least one altered cell in the painting.

翻译中…

Output

翻译中…

Print the minimum area of the brush in a line, if the painting is possibly altered, otherwise print $- 1$.

翻译中…

样例

Input #1
4 4
XX..
XX..
XXXX
XXXX
Output #1
4
InputCopy OutputCopy
Input #2
4 4
....
.XXX
.XXX
....
Output #2
2
InputCopy OutputCopy
Input #3
4 5
XXXX.
XXXX.
.XX..
.XX..
Output #3
-1
InputCopy OutputCopy
题目信息
题号
475C
时间限制
2 s
内存限制
256 MB
标签
暴力
构造
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。