#841
Gold I
DEBUG
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

While debugging a program Mirko noticed that a bug in the program may be linked with the existence of so called square killers in the program memory. The program memory is a matrix composed of R rows and C columns consisting only of zeroes and ones. A square killer is a square submatrix in memory, consisting of more than one character, that, when rotated 180 degrees looks exactly the same. For example, the following matrix contains 3 square killers:

101010
111001
101001

memory

....10
....01
......

killer

......
...00.
...00.

killer

101...
111...
101...

killer

Mirko is wondering if there is a connection between the size of the largest square killer and the bug in the program. Help Mirko by writing a program that, given the layout of the memory, outputs the size of the largest square killer. The size of the square killer is the number of rows (or columns) that the killer consists of. In the example above the killer sizes are 2, 2 and 3, respectively.

입력

The first will contain two integers, R and C, smaller than or equal to 300.

The next R lines will each contain C characters ('0' or '1') with no spaces.

출력

Output the size of the largest killer on a single line, or output -1 if there are no square killers.

예제 입력 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
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Gold I1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.