func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, totx, tot, hangx[2005], liex[2005];   double ans;   char s[2005];   long long func(int n, int m, int a[]) {     long long ret = 0;     for (int i = 1; i <= n; i++) {       long long sum = 0, cnt = m - a[i];       for (int j = 1; j <= n; j++) {         if (a[j])           sum += (m - 1) * abs(i - j);         else           sum += m * abs(i - j);       }       if (a[i])         ret += (m - 1) * sum;       else         ret += m * sum;       if (a[i]) {         int l = i - 1, r = i + 1;         while (a[l + 1] < a[l]) {           cnt += m - a[l];           l--;         }         while (a[r - 1] < a[r]) {           cnt += m - a[r];           r++;         }         ret += 4 * cnt * (a[i] - 1);       }     }     return ret;   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> s;       for (int j = 1; j <= m; j++) {         if (s[j - 1] ==  X ) {           hangx[i] = j;           liex[j] = i;           totx++;         }       }     }     tot = n * m - totx;     ans = (func(n, m, hangx) + func(m, n, liex)) * 1.0 / tot / tot;     cout << fixed << setprecision(12) << ans << endl;     return 0;   }   