How to do matrix conversions by row and columns toggles?

后端 未结 8 2016
半阙折子戏
半阙折子戏 2021-01-13 12:01

I have got a square matrix consisting of elements either 1 or 0. An ith row toggle toggles all the ith row elements (1 becomes 0 and vice versa) and jth column toggle toggle

8条回答
  •  情歌与酒
    2021-01-13 12:09

    If you can only toggle the rows, and not the columns, then there will only be a subset of matrices that you can convert into the final result. If this is the case, then it would be very simple:

    for every row, i:
      if matrix1[i] == matrix2[i]
        continue;
      else
        toggle matrix1[i];
        if matrix1[i] == matrix2[i]
          continue
        else
          die("cannot make similar");
    

提交回复
热议问题