1072.cpp (461B)
1 class Solution { 2 typedef bitset<512> bs_t; 3 4 public: 5 int maxEqualRowsAfterFlips(const vector<vector<int>> &matrix) { 6 int n = matrix.size(), m = matrix[0].size(), res = 0; 7 unordered_map<bs_t, int> um; 8 for (int i = 0; i < n; i++) { 9 bs_t crnt; 10 for (int j = 0; j < m; j++) 11 crnt[j] = matrix[i][j] != matrix[i][0]; 12 res = max(res, ++um[crnt]); 13 } 14 return res; 15 } 16 };