Created
March 5, 2018 02:03
-
-
Save igomez10/e7bce78d992923ac7923ac9a7af98738 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
def getBiggestRegion(grid): | |
def size(i, j): | |
if 0 <= i < len(grid) and 0 <= j < len(grid[i]) and grid[i][j] == 1: | |
grid[i][j] = 0 | |
counter = sum([size(i2,j2) for i2 in range(i-1, i+2) for j2 in range(j-1, j+2)]) | |
return 1 + counter | |
return 0 | |
return(max( size(a,b) for a in range(len(grid)) for b in range( len(grid[a])) )) | |
n = int(input().strip()) | |
m = int(input().strip()) | |
grid = [] | |
for grid_i in range(n): | |
grid_t = list(map(int, input().strip().split(' '))) | |
grid.append(grid_t) | |
print(getBiggestRegion(grid)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment