4378 - 가장 큰 조각 1

Time Limit: 1s Memory Limit: 128MB

Submissions: 849 Solved: 421
Description

0과 1로 채워진 사각행렬이 주어졌을 때, 1로 채워진 가장 큰 부분 행렬을 찾는 프로그램을 작성하세요. (동일한 크기가 여러개 일 경우에는 i, j 우선순위로 가장 가까운 사각행렬을 출력)

Given a square matrix with the elements 0 or 1, write a program to find a maximum square submatrix whose elements are all 1s. Your program should prompt the user to enter the number of rows in the matrix. The program then displays the location of the first element in the maximum square submatrix and the number of the rows in the submatrix.

 

Input

* Line 1 : 행의개수N (N은 1~20범위의 정수)

* Line 2 ~ N+1 : 공백으로 구분된 N개의 0 또는 1

Output

* Line 1 : i j k
- i: 부분행렬의 시작행 (0부터시작)
- j: 부분행렬의 시작열 (0부터시작)
- k: 부분행렬의 크기

Sample Input
5
1 0 1 0 1
1 1 1 0 1
1 0 1 1 1
1 0 1 1 1
1 0 1 1 1
Sample Output
2 2 3
Source

JAVA2015 PE8.35