Question : Timus - 1060 - Flip Game

Basically you have a 4*4 grid of black or white cells. If you flip one cell, all of its 4 neighbours also get flipped. Your task to find if the grid can be made to all-white or all-black (minimum moves) or tell if it’s impossible. I tried recursion but it’s too slow. Is this a question on bitmasks? Some of the discussion forums have solutions converting the grid into a 1-D binary number and then checking to convert it into 0 or 65536 (using some weird hex values).

Can anyone explain how it works?

Yes I think u should try with bitmasks ,there was a similar problem in atcoder beginner contest once.