#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 最大正方形
# @param matrix char字符型二维数组 
# @return int整型
#
class Solution:
    def solve(self , matrix: List[List[str]]) -> int:
        # write code here
        y_len = matrix.__len__()
        if y_len == 0: return 0
        x_len = matrix[0].__len__()
        for l in range(min(y_len, x_len),0 ,-1):
            for y in range(y_len - l + 1):
                for x in range(x_len - l + 1):
                    l_flag = True
                    for i, zs in enumerate(matrix[y: l+y]):
                        zs = zs[x: l+x]
                        if (i==0 or i==l-1) and '0' in zs:
                            l_flag = False
                            break
                        if '0' in [zs[0], zs[-1]]:
                            l_flag = False
                            break
                    if l_flag:
                        return l * l
        return 0