#K52922. Largest Square Subgrid
Largest Square Subgrid
Largest Square Subgrid
You are given a grid with R rows and C columns composed of characters '0' and '1'. Your task is to find the side length of the largest square subgrid that contains only '1's. A classic dynamic programming solution is to use the recurrence:
\( dp[i][j] = \min\{ dp[i-1][j],\; dp[i][j-1],\; dp[i-1][j-1] \} + 1 \) if the cell (i, j) contains '1', otherwise 0.
Output the maximum side length found. This problem tests your ability to implement a dynamic programming solution on a grid.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains two integers R and C separated by a space, representing the number of rows and columns.
- The following R lines each contain a string of length C consisting of the characters '0' and '1'.
outputFormat
Output a single integer to standard output (stdout), which is the side length of the largest square subgrid that is composed entirely of '1's.
## sample5 5
11011
11111
01110
01111
01111
3