func_code_string: #include <bits/stdc++.h>   using namespace std;   long long n, m, a[1005], b[1005], c[1005], d[1005], ans, tot;   ;   char s[1005];   long long calc() {     long long cc = 0;     for (long long i = 1; i <= n; i++)       if (c[i]) {         ans += (c[i] - 1) * (m - c[i]) * 4;         for (long long j = i + 1; j <= n; j++)           if (!c[j] || c[j] < c[j - 1])             break;           else             cc += (c[i] - 1) * (m - c[j]) * 4;         for (long long j = i + 1; j <= n; j++)           if (!c[j] || c[j] > c[j - 1])             break;           else             cc += (c[j] - 1) * (m - c[i]) * 4;       }     return cc;   }   int main() {     scanf( %I64d%I64d , &n, &m);     for (long long i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (long long j = 1; j <= m; j++)         if (s[j] ==  . )           tot++, a[i]++, b[j]++;         else           c[i] = j, d[j] = i;     }     long long o, ct, su;     o = ct = su = 0;     for (long long i = 1; i <= n; i++) o += su * a[i], ct += a[i], su += ct;     ans = o * 2;     o = ct = su = 0;     for (long long i = 1; i <= m; i++) o += su * b[i], ct += b[i], su += ct;     ans += o * 2;     ans += calc();     swap(n, m);     for (long long i = 1; i <= n; i++) c[i] = d[i];     ans += calc();     printf( %.16lf , ((double)ans) / tot / tot);     return 0;   }   