Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef vector<int> vi;
- #define PB push_back
- const int MAXN = 2007;
- vi p[MAXN][MAXN];
- bitset<MAXN> b[MAXN], prz;
- void solve(){
- int n, m;
- cin >> n >> m;
- for(int i=1; i<=n; i++){
- for(int j=1; j<=m; j++){
- int x;
- cin >> x;
- p[j][x].PB(i);
- }
- }
- for(int i=1; i<=m; i++){
- for(int vl=1; vl<1000; vl++){
- for(auto &x : p[i][vl]) prz[x] = 1;
- for(auto &x : p[i][vl]) b[x] ^= prz;
- for(auto &x : p[i][vl]) prz[x] = 0;
- }
- }
- ll ans = 0;
- for(int i=1; i<=n; i++) ans += b[i].count();
- if(m % 2) ans -= n;
- ans /= 2;
- cout << ans << "\n";
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement