func_code_string: #include <bits/stdc++.h>   using namespace std;   const int dim = 52;   char a[dim][dim];   int s[dim][dim];   int dp[dim][dim][dim][dim];   void compute(int i1, int j1, int i2, int j2) {     if (dp[i1][j1][i2][j2] != 0x3f3f3f3f) return;     int ans = max(i2 - i1 + 1, j2 - j1 + 1);     if (s[i2][j2] - s[i1 - 1][j2] - s[i2][j1 - 1] + s[i1 - 1][j1 - 1] == 0) {       dp[i1][j1][i2][j2] = 0;       return;     }     if (s[i2][j2] - s[i1 - 1][j2] - s[i2][j1 - 1] + s[i1 - 1][j1 - 1] ==         (i2 - i1 + 1) * (j2 - j1 + 1)) {       dp[i1][j1][i2][j2] = ans;       return;     }     for (int i = i1; i < i2; ++i) {       compute(i1, j1, i, j2);       compute(i + 1, j1, i2, j2);       ans = min(ans, dp[i1][j1][i][j2] + dp[i + 1][j1][i2][j2]);     }     for (int j = j1; j < j2; ++j) {       compute(i1, j1, i2, j);       compute(i1, j + 1, i2, j2);       ans = min(ans, dp[i1][j1][i2][j] + dp[i1][j + 1][i2][j2]);     }     dp[i1][j1][i2][j2] = ans;   }   void solve() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i] + 1;       for (int j = 1; j <= n; ++j)         s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (a[i][j] ==  # );     }     memset(dp, 0x3f, sizeof dp);     compute(1, 1, n, n);     cout << dp[1][1][n][n];   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(false);     solve();     return 0;   }   