Room lights

A house has n x m rooms (n, m >= 2) they're represented by a matrix with n rows (from 0 to n-1) and m columns (from 0 to m-1).
Every room, expect the first row (i = 0) and first column (j = 0), has a switch. Using the switch from the room (i,j) leads to this: in every room (i,j) (i-1,j) (i,j-1) (i-1,j-1), if the light is on it gets off and otherwise it gets on.

Write a C++ function which receives three parameters:
An A matrix ( with 0 and 1 elements represented by the light status of the room) and also the size of that matrix n and m, which returns 1 if there's a multitude of rooms that can be switch such that turns all lights off or 0 if it's not possible.

Can anyone please tell me what method should i use and if possible, how it should be resolved.
Topic archived. No new replies allowed.