""" name: Nicholas Tamassia Honor Code and Acknowledgments: This work complies with the JMU Honor Code. Comments here on your code and submission. """ def explore_island(grid: list[list[int]], start: tuple[int, int]) -> int: num_rows: int = len(grid) num_cols: int = len(grid[0]) size: int = 0 def recurse(coord: tuple[int, int]): x, y = coord if grid[y][x] == 0: return nonlocal size size += 1 grid[y][x] = 0 if y > 0: recurse((x, y - 1)) if y < num_rows - 1: recurse((x, y + 1)) if x > 0: recurse((x - 1, y)) if x < num_cols - 1: recurse((x + 1, y)) recurse(start) return size # All modules for CS 412 must include a main method that allows it # to imported and invoked from other python scripts def main(): n: int = int(input()) land_grid: list[list[int]] = [list(map(int, input().split())) for _ in range(0, n)] num_rows: int = n num_cols: int = len(land_grid[0]) largest_island: int = -1 for y in range(0, num_rows): for x in range(0, num_cols): if land_grid[y][x] == 0: continue island_size: int = explore_island(land_grid, (x, y)) if island_size > largest_island: largest_island = island_size print(largest_island) if __name__ == "__main__": main()