Problem C

Statement
Copy Copied
Description:
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 Format:
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 Format:
Print the minimum area of the brush in a line, if the painting is possibly altered, otherwise print  - 1.

Note:
None

Submissions

IDLanguageExit CodeTimestampCodeStdoutStderrRetry
5359 go 0 2026-03-14T04:29:50.165308Z View View View Retry
5339 go 0 2026-03-13T10:05:24.691837Z View View View Retry
5333 go 1 2026-03-13T09:55:14.32386Z View View View Retry
5313 go 1 2026-03-13T07:57:57.228346Z View View View Retry

Evaluations

Eval IDRun IDProviderModelLangSuccessTimestampPromptResponseStdoutStderrRetry
2463 20260314-020006 openai gpt-5.4 go false 2026-03-14T02:44:17.770543Z View View View View Retry
2384 20260313-045546 gemini gemini-3-pro-preview go false 2026-03-13T06:01:54.517867Z View View View View Retry