BZOJ原题链接 洛谷原题链接 设\(L[i][j],R[i][j],H[i][j]\)表示点\((i,j)\)向左.右.上尽量拓展的左端点.右端点.上端点的坐标. \(L,R\)直接初始化好,\(H\)则全部为\(1\). 扫过整个矩阵,对于每个点,尽量去拓展上端点,并更新\(L[i][j] = \max\{ L[i][j], L[i - 1][j] \}, R[i][j] = \min\{ R[i][j], R[i - 1][j] \}, H[i][j] = H[i - 1][j] + 1\…