The bishop can go to 4 directions (diagonally).

The number of cells in the upper-left direction (the bishop can attack) is: min( x-1, y-1 )

The number of cells in the lower-left direction (the bishop can attack) is: min( x-1, M-y )

The number of cells in the upper-right direction (the bishop can attack) is: min( N-x, y-1 )

The number of cells in the lower-right direction (the bishop can attack) is: min( N-x, M-y )

So the total number of cells (the bishop can attack) is min( x-1, y-1 ) + min( x-1, M-y ) + min( N-x, y-1 ) + min( N-x, M-y ) + 1

Statistics

80% Solution Ratio
ruhanhabib39Earliest, Dec '16
abdullah2222Fastest, 0.0s
ruhanhabib39Lightest, 131 kB
mdvirusShortest, 125B
Toph uses cookies. By continuing you agree to our Cookie Policy.