func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1000005;   const int MAXN = 1e5 + 5;   const int LG = 22;   int dp[51][51][51][51];   int n;   int a[55][55];   int get(int tli, int tlj, int rbi, int rbj) {     int res = a[rbi][rbj];     if (tli > 0) res = res - a[tli - 1][rbj];     if (tlj > 0) res = res - a[rbi][tlj - 1];     if (tli > 0 && tlj > 0) res = res + a[tli - 1][tlj - 1];     return res;   }   int foo(int r1, int r2, int c1, int c2) {     if (r1 > r2 or c1 > c2) return 0;     if (dp[r1][r2][c1][c2] != -1) return dp[r1][r2][c1][c2];     int ans = (get(r1, c1, r2, c2) > 0) * max(r2 - r1 + 1, c2 - c1 + 1);     for (int i = r1; i < r2; i++) {       ans = min(ans, foo(r1, i, c1, c2) + foo(i + 1, r2, c1, c2));     }     for (int i = c1; i < c2; i++) {       ans = min(ans, foo(r1, r2, c1, i) + foo(r1, r2, i + 1, c2));     }     return dp[r1][r2][c1][c2] = ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     string s[n];     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (s[i][j] ==  # ) {           a[i][j] = 1;         }       }     }     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++)         for (int ii = 0; ii < n; ii++)           for (int jj = 0; jj < n; jj++) dp[i][ii][j][jj] = -1;     for (int i = 0; i < n; i++) {       for (int j = 1; j < n; j++) {         a[i][j] += a[i][j - 1];       }     }     for (int i = 1; i < n; i++) {       for (int j = 0; j < n; j++) {         a[i][j] += a[i - 1][j];       }     }     int ans = foo(0, n - 1, 0, n - 1);     cout << ans <<   n ;     return 0;   }   