Help needed

Can someone pls give me hint for this question

The constraints


Bruteforce! as contstraints are very small.

i was reading editorial and i am unable to understand this line can you help me with it
if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0

Do you understand the point of the line?

yes we r taking it as ,whether we mark ith row or jth column marked or not thats why we r using 2^h value (one when we take it as red and once when we don’t ) right?


how’s this line working
if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0
i mean i know what it’s doing but can’t figure out how?

It checks if the i-th bit is set. Say you have some number in binary, like 13 = 1101. If you want to check the first bit (from the right), you just check if it’s odd. If you want to check the second, you’d right-shift the number by one, then check if it’s odd, and so on.

1 Like

oh yeah i got it now thanks btw