JZPLIT - Turn on the lights
Recently Zippy received a puzzle. It is an n×m matrix. In each cell of the matrix, there is a switch and a light. Once he flips the switch in a cell, lights in the same column or the same row as the cell (including itself) change to its opposite state (which means: on → off, off → on). Zippy wants to turn on all the lights. Please help him to solve the puzzle.
Input
First line, n, m.
The following n lines, each line is a m-length string, representing the original state. (0 means on and 1 means off)
1 ≤ n, m ≤ 1000
Output
n lines, each line is a m-length string. It's obvious that if a valid solution exists, there exists a solution that every switch is flipped no more than once. So 1 means the switch is flipped once and 0 means the switch remains unflipped.
It's guaranteed that there always exists a solution. If there are multiple solutions, output any of them.
Example
Input: 2 3 010 010 Output: 010 101
Added by: | sevenkplus |
Date: | 2011-09-12 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |