问题 R: Largest Submatrix

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

Now here is a matrix with letter 'a','b','c','w','x','y','z' and you can change 'w' to 'a' or 'b', change 'x' to 'b' or 'c', change 'y' to 'a' or 'c', and change 'z' to 'a', 'b' or 'c'. After you changed it, what's the largest submatrix with the same letters you can make?

输入

The input contains multiple test cases. Each test case begins with m and n (1≤m,n≤1000) on line. Then come the elements of a matrix in row-major order on m lines each with n letters. The input ends once EOF is met.

输出

For each test case, output one line containing the number of elements of the largest submatrix of all same letters.

样例输入 复制

2 4
abcw
wxyz

样例输出 复制

3

来源/分类