Precompute the number of consecutive 1 below the ( i , j ) in j - th column and the number of consecutive 1 s on right side of ( i , j ) in i - th row .
static void precompute ( int mat [ ] [ ] , int ryt [ ] [ ] , int dwn [ ] [ ] ) {