1992. 找到所有的农场组

从两边延伸,退耕还林

def find_farmland(land):
    m, n, res = len(land), len(land[0]), []
    for i in range(m):
        for j in range(n):
            if land[i][j] == 1:
                r, c = i, j
                while r < m - 1 and land[r + 1][j] == 1:
                    r = r + 1
                while c < n - 1 and land[i][c + 1] == 1:
                    c = c + 1
                res.append([i, j, r, c])
                for n1 in range(i, r + 1):
                    for n2 in range(j, c + 1):
                        land[n1][n2] = 0
    return res```

上一篇:【Luogu P2704】[NOI2001] 炮兵阵地


下一篇:Mysql(CAST)和Oracle(to_char)应用