func_code_string: #include <bits/stdc++.h>   using namespace std;   const int dx[] = {0, 1, -1, 0, 0};   const int dy[] = {0, 0, 0, 1, -1};   struct MinCostMaxFlow {     int head[20010], total;     int next[1000010], aim[1000010], flow[1000010], cost[1000010];     int f[20010], from[20010], p[20010];     bool v[20010];     MinCostMaxFlow() : total(1) {}     void Add(int x, int y, int f, int c) {       next[++total] = head[x];       aim[total] = y;       flow[total] = f;       cost[total] = c;       head[x] = total;     }     void Insert(int x, int y, int f, int c) {       Add(x, y, f, c);       Add(y, x, 0, -c);     }     bool SPFA() {       static queue<int> q;       while (!q.empty()) q.pop();       memset(f, 0x3f, sizeof(f));       memset(v, false, sizeof(v));       f[0] = 0;       q.push(0);       while (!q.empty()) {         int x = q.front();         q.pop();         v[x] = false;         for (int i = head[x]; i; i = next[i])           if (flow[i] && f[aim[i]] > f[x] + cost[i]) {             f[aim[i]] = f[x] + cost[i];             if (!v[aim[i]]) v[aim[i]] = true, q.push(aim[i]);             from[aim[i]] = x;             p[aim[i]] = i;           }       }       return f[(20010 - 1)] != 0x3f3f3f3f;     }     int EdmondsKarp() {       int re = 0;       while (SPFA()) {         int max_flow = 0x3f3f3f3f;         for (int i = (20010 - 1); i != 0; i = from[i])           max_flow = ((max_flow) < (flow[p[i]]) ? (max_flow) : (flow[p[i]]));         for (int i = (20010 - 1); i != 0; i = from[i]) {           flow[p[i]] -= max_flow;           flow[p[i] ^ 1] += max_flow;         }         re += f[(20010 - 1)] * max_flow;       }       return re;     }   } solver;   int m, n;   int src[110][110];   int main() {     cin >> m >> n;     for (int i = 1; i <= m; ++i)       for (int j = 1; j <= n; ++j) scanf( %d , &src[i][j]);     for (int i = 1; i <= m; ++i)       for (int j = 1; j <= n; ++j) {         if (i + j & 1) {           solver.Insert(0, ((i - 1) * n + j), 1, 0);           for (int k = 1; k <= 4; ++k) {             int fx = i + dx[k], fy = j + dy[k];             if (!fx || !fy || fx > m || fy > n) continue;             solver.Insert(((i - 1) * n + j), ((fx - 1) * n + fy), 1,                           src[i][j] != src[fx][fy]);           }         } else           solver.Insert(((i - 1) * n + j), (20010 - 1), 1, 0);       }     cout << solver.EdmondsKarp() << endl;     return 0;   }   