A PHP program looks like this:
$a = [ [0,0,1,1,0,0,1,1,0,1,0], [0,0,1,1,0,0,1,1,0,1,1], [0,0,1,1,1,1,1,1,0,1,0], [0,0,0,1,1,1,1,1,0,1,1], [0,0,1,1,1,1,1,1,0,1,0], [0,0,0,1,1,1,1,1,0,1,1], [0,0,1,1,1,1,1,1,0,1,0], [0,0,1,1,0,0,1,1,0,1,0], [0,0,1,1,0,0,1,1,0,1,1], [0,0,1,1,0,0,1,1,0,1,1] ]; foreach($a as $str){ print "<br>"; foreach($str as $item) print $item; } print "<br>"; $m = count($a); $n = count($a[0]); $side = 0; for($i = 0; $i < $m; $i++){ for($j = 0; $j < $n; $j++){ if ($i*$j == 0) continue; if($a[$i][$j] == 1) $a[$i][$j] = min($a[$i][$j-1], $a[$i-1][$j], $a[$i-1][$j-1]) + 1; if ($a[$i][$j]>$side) $side=$a[$i][$j]; } } foreach($a as $str){ print "<br>"; foreach($str as $item) print $item; } printf("<br><br>Площадь максимального квадрата равна %d", $side*$side);
The conclusion is:
00110011010
00110011011
00111111010
00011111011
00111111010
00011111011
00111111010
00110011010
00110011011
00110011011
00110011010
00120012011
00121112010
00012222011
00112333010
00012344011
00112345010
00120012010
00120012011
00120012012
The maximum square is 25
It is easy to see that after the program is executed, the original matrix contains as elements the maximum side filled with matrix units with the corresponding lower right corner (the maximum is calculated from the already transformed matrix elements).
How does this happen?
For the left column and the top row, these elements already match, so they are skipped in processing.
In other cases, the current element of the matrix increases, provided that it is equal to 1. At the same time, the minimum of the three elements bordering the current element on the left, top and left-top is taken as the base for the increase.
A simple analysis of the pictures shows that this formula is correct.
PS Let's conduct this analysis for the next current state of the matrix. 
When forming the next element (which is still equal to 1), the following facts are used:
- The next element is equal to one (if it would be zero, then the side of the square, too)
- The maximum square on the left-top of the next element (black square) has side 3, therefore the maximum side of the new square cannot be greater than 4. In general, this restriction is equal to the length of the side of the black square plus 1.
- Under the conditions of point 2, the length of the filled green bar is equal to the side of the green square and is 3, therefore the maximum side of the new square cannot be greater than 4. In general, this restriction is equal to the side of the green square plus 1.
- Under the conditions of paragraph 2, the length of the filled red strip is equal to the side of the red square and equal to 3, therefore the maximum side of the new square cannot be greater than 4. In general, this restriction is equal to the side of the red square plus 1.
- Since nn. 1-4 exhaust the list of possible constraints, then, with step 1, the maximum length of the side of the filled square with the lower right corner on the next element of the matrix is equal to the minimum of this value in black, green and red squares, increased by one.