Construct a bipartite graph in which one set of vertices corresponds to the rows and the other corresponds to the columns of the board. There is an edge from i to j if a[i,j] = 1. The problem asks to find the minimum edge coloring of the graph, i.e. to find the minimum number of colors to color the edges such that none of adjacent edges have the same color.
Minimum edge coloring in general graph is shown to be NP-hard, although an interesting result (Vizing’s theorem) says that the minimum number of colors needed (or edge chromatic number) is either D or D+1, for D is the maximum degree of the graph.
However, on bipartite graph, minimum edge coloring is shown to be in P. A theorem by Konig says that in bipartite graph, edge chromatic number is equal to maximum degree. The theorem also suggests an O(VE) algorithm to find the minimum edge coloring.
A proof about Konig’s theorem can be found here http://www.kurims.kyoto-u.ac.jp/~iwata/dmi/dmi01e.pdf. There is O(ElogE) time algorithm has been developed, for example http://ecommons.cornell.edu/handle/1813/6283. Some contestants manage to optimize the O(VE) to run into the time limit.