Largest Square
Time limit5sMemory limit256 MB
Given a 0/1 matrix, find the side length of the largest all-ones square submatrix.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Matrix
- Solved
- No attempts yet
Problem
Given an matrix made up of s and s, write a program that finds the largest square submatrix consisting entirely of s.
Input
The input consists of several test cases. The first line of each test case contains and (). Each of the next lines contains numbers separated by spaces. The input ends with a line containing two zeros.
Output
For each test case, output the side length (width or height) of the largest square. If no such square exists, output .