Advertisement
Guest User

Untitled

a guest
Apr 8th, 2024
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. typedef vector<int> vi;
  6.  
  7. #define PB push_back
  8. const int MAXN = 2007;
  9.  
  10. vi p[MAXN][MAXN];
  11. bitset<MAXN> b[MAXN], prz;
  12.  
  13. void solve(){
  14.     int n, m;
  15.     cin >> n >> m;
  16.  
  17.     for(int i=1; i<=n; i++){
  18.         for(int j=1; j<=m; j++){
  19.             int x;
  20.             cin >> x;
  21.             p[j][x].PB(i);
  22.         }
  23.     }
  24.    
  25.     for(int i=1; i<=m; i++){
  26.         for(int vl=1; vl<1000; vl++){
  27.             for(auto &x : p[i][vl]) prz[x] = 1;
  28.             for(auto &x : p[i][vl]) b[x] ^= prz;
  29.             for(auto &x : p[i][vl]) prz[x] = 0;
  30.         }
  31.     }
  32.    
  33.     ll ans = 0;
  34.     for(int i=1; i<=n; i++) ans += b[i].count();
  35.     if(m % 2) ans -= n;
  36.     ans /= 2;
  37.     cout << ans << "\n";
  38. }
  39.  
  40. int main(){
  41.     ios_base::sync_with_stdio(false);
  42.     cin.tie(NULL);
  43.     cout.tie(NULL);
  44.     solve();
  45.     return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement