#P4858. [PA 2013] Karty

[PA 2013] Karty

Problem Description

Given an n×mn \times m rectangle, each cell is either _ or X. Choose the largest possible r×cr \times c rectangle such that multiple r×cr \times c rectangles (overlapping is allowed) can cover all X cells, and do not cover any _ cells.

Input Format

The first line contains n,mn, m, as described above.

The next nn lines each contain a string of length mm describing the matrix.

Output Format

Output one line with two integers r,cr, c, separated by a space.

If there are multiple choices with the maximum area, output the one with the smallest rr.

4 5
_XXX_
XXXX_
XXXXX
_XXXX
2 3

Hint

Constraints: for 100%100\% of the testdata, 1n,m2.5×1031 \le n, m \le 2.5 \times 10^3.

Translated by ChatGPT 5