lastState
with the decision and changed
with all zeros.state
based on changed
.lastState
at that cell is 1
, flip the current cell and its neighbors, and increment the flip counter.changed
and lastState
for the next row.lastState
is all zeros to determine if the solution is valid.-1
if no valid solution exists.