func_code_string: #include <bits/stdc++.h>   using namespace std;   struct segment {     int l, r, fu;     bool operator<(const segment &temp) const { return l < temp.l; }   };   segment sg[5000];   int cnt_sg;   const int inf = 1e9;   int xx[400], yy[400];   int cnt_x, cnt_y;   struct rectangle {     int lx, ly, rx, ry;   };   rectangle rec[99];   int n, m, k, cnt, mc[1111][1111], nc[1111][11111], list[99], cnt_list, ls[99],       cnt_ls;   long long ans, now;   char str[1111][1111];   bool vsx[400], vsy[400];   int main() {     int i, j, s, p, q, id, dx1, dx2, dy1, dy2, lx, ly, rx, ry, pn;     scanf( %d%d%d , &n, &m, &k);     for (i = 0; i < n; i++) scanf( %s , str[i]);     cnt = 0;     for (i = 0; i < n; i++)       for (j = 0; j < m; j++) {         if (str[i][j] ==  *  && !(i > 0 && str[i - 1][j] ==  * ) &&             !(j > 0 && str[i][j - 1] ==  * )) {           rec[cnt].lx = i;           rec[cnt].ly = j;           for (s = i; s < n; s++) {             for (p = j; p < m; p++) {               if (str[s][p] !=  * ) break;             }             if (p == j) break;             rec[cnt].ry = p - 1;           }           rec[cnt++].rx = s - 1;         }       }     memset(mc, 0, sizeof(mc));     memset(nc, 0, sizeof(nc));     for (i = 0; i < k; i++) mc[rec[i].lx][rec[i].ly]++;     for (i = 0; i < n; i++)       for (j = 0; j < m; j++) {         mc[i + 1][j] += mc[i][j];         mc[i][j + 1] += mc[i][j];         mc[i + 1][j + 1] -= mc[i][j];       }     cnt_x = cnt_y = 0;     for (i = 0; i < k; i++) {       xx[cnt_x++] = rec[i].lx;       xx[cnt_x++] = rec[i].rx;       if (rec[i].lx - 1 >= 0) xx[cnt_x++] = rec[i].lx - 1;       if (rec[i].rx + 1 < n) xx[cnt_x++] = rec[i].rx + 1;       yy[cnt_y++] = rec[i].ly;       yy[cnt_y++] = rec[i].ry;       if (rec[i].ly - 1 >= 0) yy[cnt_y++] = rec[i].ly - 1;       if (rec[i].ry + 1 < m) yy[cnt_y++] = rec[i].ry + 1;     }     sort(xx, xx + cnt_x);     sort(yy, yy + cnt_y);     int nn = 0;     for (i = 0; i < cnt_x; i++) {       if (nn == 0 || xx[nn - 1] < xx[i]) xx[nn++] = xx[i];     }     cnt_x = nn;     nn = 0;     for (i = 0; i < cnt_y; i++) {       if (nn == 0 || yy[nn - 1] < yy[i]) yy[nn++] = yy[i];     }     cnt_y = nn;     ans = 0;     for (i = 0; i < cnt_x; i++) {       if (i == 0)         dx1 = xx[i] + 1;       else         dx1 = xx[i] - xx[i - 1];       for (j = i + 1; j <= cnt_x; j++) {         if (j == cnt_x)           dx2 = n - xx[j - 1];         else           dx2 = xx[j] - xx[j - 1];         cnt_sg = 0;         for (s = 0; s < k; s++) {           if (rec[s].rx < xx[i] || rec[s].lx > xx[j - 1]) continue;           if ((rec[s].rx >= xx[i] && rec[s].lx < xx[i]) ||               (rec[s].rx > xx[j - 1] && rec[s].lx <= xx[j - 1]))             sg[cnt_sg].fu = 1;           else             sg[cnt_sg].fu = 0;           sg[cnt_sg].l = rec[s].ly;           sg[cnt_sg++].r = rec[s].ry;         }         sort(sg, sg + cnt_sg);         nn = 0;         for (s = 0; s < cnt_sg; s++) {           if (nn == 0 || sg[nn - 1].r < sg[s].l)             sg[nn++] = sg[s];           else if (sg[nn - 1].r < sg[s].r) {             sg[nn - 1].r = sg[s].r;             sg[nn - 1].fu = max(sg[nn - 1].fu, sg[s].fu);           }         }         cnt_sg = nn;         for (s = 1; s <= cnt_sg; s++) {           if (s < cnt_sg)             dy2 = sg[s].l - sg[s - 1].r;           else             dy2 = m - sg[s - 1].r;           pn = 0;           for (p = s - 1; p >= 0; p--) {             lx = xx[i];             ly = sg[p].l;             rx = xx[j - 1];             ry = sg[s - 1].r;             int rs = mc[rx][ry];             if (lx > 0) rs -= mc[lx - 1][ry];             if (ly > 0) rs -= mc[rx][ly - 1];             if (lx > 0 && ly > 0) rs += mc[lx - 1][ly - 1];             if (rs > 3 || sg[p].fu == 1) break;             if (rs == 0) continue;             if (p == 0)               dy1 = sg[p].l + 1;             else               dy1 = sg[p].l - sg[p - 1].r;             for (q = 0; q < k; q++) {               if (rec[q].lx >= lx && rec[q].rx <= rx && rec[q].ly >= ly &&                   rec[q].ry <= ry)                 continue;               if (rec[q].lx <= rx && rec[q].rx >= xx[i] && rec[q].ly <= ry &&                   rec[q].ry >= ly)                 break;             }             if (q >= k) pn += dy1;           }           ans += (long long)pn * (long long)dy2 * (long long)dx1 * (long long)dx2;         }       }     }     printf( %I64d n , ans);     return 0;   }   