You can check if the chessboard is consistent by checking if all the black cells have same parity and all the white cells have different parity.

Let's a cell's position is (x, y), then let's define it's parity as (x+y)%2. You can easily see that, by our definition, every adjacent pair of cells will have different parity.

So the complexity for a test case is: O(Q)

Statistics

48% Solution Ratio
NirjhorEarliest, May '17
Kuddus.6068Fastest, 0.0s
NirjhorLightest, 131 kB
SIR.24Shortest, 506B
Toph uses cookies. By continuing you agree to our Cookie Policy.