Advertisement
Mohammad_Dipu_Sultan

Flip Columns_SRBD

Oct 15th, 2023
771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6.     int n, m, k;
  7.     cin >> n >> m >> k;
  8.     vector<int>f(n, 0);
  9.     for(int i = 0; i < n; i++){
  10.         for(int j = 0; j < m; j++){
  11.             int x;
  12.             cin >> x;
  13.             if(x==1){
  14.                 f[i] = f[i] | (1 << j);
  15.             }
  16.         }
  17.     }
  18.     map<int, int>mp;
  19.     for(int i = 0; i < n; i++){
  20.         mp[f[i]]++;
  21.     }
  22.     int ans  = 0;
  23.     for(auto &[a, b]: mp){
  24.         int x = m - __builtin_popcount(a);
  25.         if(x <= k and (k-x)%2==0){
  26.             ans = max(ans, b);
  27.         }
  28.     }
  29.     cout << ans << endl;
  30. }
  31.  
  32. /*
  33. 3 3 2
  34. 1 0 0
  35. 1 0 1
  36. 1 0 0
  37.  
  38. 2
  39. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement