#Lutece1042. Ideal matrix
Ideal matrix
Migrated from Lutece 1042 Ideal matrix
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Dave has a big matrix with a lowercase in each cell. In this matrix, he find some small matrix very attractive, he call them ieadl matrix.
A matrix is a ieadl matrix when it matches following conditions.
- For each row, nomatter you read it from right to left or from left to right, it would be same;
- For each column, nomatter you read it from bottom to front or from front to bottom, it would be same;
example:
a b a a b b
c c c c c c
a b a a b a
Frist one is a ideal matrix. And second is not,beacuse in first row, when you read it from left to right,it is abb
,and when you read it from right to left it is bba
. now he want to konw biggest size ideal matrix he can find in this big matrix.
Input
Frist line has tow element , indicate number of rows and number of column.
Following line, each have lowercase.
Output
One number, indecate the answer.
Samples
4
dbda
cfcb
dbdc
defg
9
3
abc
def
ghi
1
4
abcd
efgh
abcd
abcd
3
Resources
The 13th UESTC Programming Contest Preliminary