title: Range update and querying in a 2D matrix
body: <p>I don't have a scenario, but here goes the problem. This is one is just driving me crazy. There is a nxn boolean matrix initially all elements are 0, n &lt;= 10^6 and given as input.
  Next there will be up to 10^5 queries. Each query can be either set all elements of column c to 0 or 1, or set all elements of row r to 0 or 1. There can be another type of query, printing the total number of 1's in column c or row r.</p>
  
  <p>I have no idea how to solve this and any help would be appreciated. Obviously a O(n) solution per query is not feasible.</p>