func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, G[1005][1005], ans = 1000000000;   char str[1005][1005];   bool vis[1005][1005];   int dfs(int x, int y, int wx, int wy) {     vis[x][y] = true;     if ((G[x + wx - 1][y + wy] - G[x - 1][y + wy] - G[x + wx - 1][y + 1 - 1] +          G[x - 1][y + 1 - 1]) == wx * wy)       return wx + dfs(x, y + 1, wx, wy);     if ((G[x + wx][y + wy - 1] - G[x + 1 - 1][y + wy - 1] - G[x + wx][y - 1] +          G[x + 1 - 1][y - 1]) == wx * wy)       return wy + dfs(x + 1, y, wx, wy);     return 0;   }   int main() {     memset(vis, false, sizeof(vis));     scanf( %d%d n , &n, &m);     int flag = 0, px, py;     for (int i = 1; i <= n; i++) scanf( %s , str[i] + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         if (str[i][j] ==  X ) {           if (!flag) {             flag = 1;             px = i;             py = j;           }           G[i][j] = G[i - 1][j] + G[i][j - 1] - G[i - 1][j - 1] + 1;         } else           G[i][j] = G[i - 1][j] + G[i][j - 1] - G[i - 1][j - 1];       }     int tmp, wx, wy;     for (tmp = px; str[tmp][py] ==  X ; tmp++)       ;     wx = tmp - px;     for (int i = py; str[px][i] ==  X ; i++)       if (dfs(px, py, wx, i - py + 1) + wx * (i - py + 1) == G[n][m])         ans = min(ans, wx * (i - py + 1));     for (tmp = py; str[px][tmp] ==  X ; tmp++)       ;     wy = tmp - py;     for (int i = px; str[i][py] ==  X ; i++)       if (dfs(px, py, i - px + 1, wy) + (i - px + 1) * wy == G[n][m])         ans = min(ans, (i - px + 1) * wy);     if (ans <= n * m)       printf( %d n , ans);     else       printf( -1 n );     return 0;   }   