QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 32 MB 満点: 120

#17550. 调试

統計

Mirko 在调试程序时注意到,程序中的一个 bug 可能与程序内存中存在的所谓“正方形杀手”(square killers)有关。程序内存是一个由 $R$ 行 $C$ 列组成的矩阵,仅包含字符 '0' 和 '1'。一个“正方形杀手”是指内存中的一个正方形子矩阵,它包含多于一个字符(即边长大于 1),且在旋转 180 度后看起来完全相同。例如,以下矩阵包含 3 个正方形杀手:

内存 (memory) 杀手 (killer) 杀手 (killer) 杀手 (killer)
101010 ....10 ...... 101...
111001 ....01 ...00. 111...
101001 ...... ...00. 101...

Mirko 想知道最大正方形杀手的大小与程序中的 bug 之间是否存在某种联系。请编写一个程序,在给定内存布局的情况下,输出最大正方形杀手的大小,以此来帮助 Mirko。正方形杀手的大小是指该杀手所包含的行数(或列数)。在上面的例子中,杀手的大小分别为 2、2 和 3。

输入格式

第一行包含两个整数 $R$ 和 $C$,均小于或等于 300。

接下来的 $R$ 行,每行包含 $C$ 个字符('0' 或 '1'),字符之间没有空格。

输出格式

在单行中输出最大正方形杀手的大小。如果不存在任何正方形杀手,则输出 -1。

样例

输入样例 1

3 6
101010
111001
101001

输出样例 1

3

输入样例 2

4 5
10010
01010
10101
01001

输出样例 2

3

输入样例 3

3 3
101
111
100

输出样例 3

-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.