func_code_string: #include <bits/stdc++.h>   template <class T>   inline void read(T &x) {     x = 0;     int ne = 0;     char c;     while (!isdigit(c = getchar())) ne = c ==  - ;     x = c - 48;     while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - 48;     x = ne ? -x : x;     return;   }   const int maxn = 1005;   const int inf = 0x7fffffff;   int g[maxn][maxn];   int okx[maxn][maxn], oky[maxn][maxn];   int sum[maxn][maxn];   bool flag[maxn][maxn];   char s[maxn];   int n, m;   struct Star {     int x, y, size;     Star(int a, int b, int c) { x = a, y = b, size = c; }     Star() { ; }   } st[1000005];   int tot = 0;   int len;   inline bool solve(int i, int j) {     int p = 1, k = 0;     len = 0;     while (p != 0) {       int x = p + k;       if (j - x >= 1 && j + x <= m && i + x <= n && i - x >= 1 &&           (sum[i][j] - sum[i][j - 1] - sum[i - x - 1][j] +                sum[i - x - 1][j - 1] >=            (x + 1)) &&           (sum[i + x][j] - sum[i + x][j - 1] - sum[i - 1][j] +                sum[i - 1][j - 1] >=            (x + 1))) {         if ((sum[i][j] - sum[i][j - x - 1] - sum[i - 1][j] +                  sum[i - 1][j - x - 1] >=              (x + 1)) &&             (sum[i][j + x] - sum[i - 1][j + x] - sum[i][j - 1] +                  sum[i - 1][j - 1] >=              (x + 1))) {           k += p, p = p << 1;           x = p + k;         } else           p = p / 2;       } else         p = p / 2;       x = p + k;       while (j - x < 1 || j + x > m || i + x > n || i - x < 1 && p) {         p = p >> 1;         x = p + k;       }     }     len = k;     if (!len) return 0;     okx[i][j - len]++, okx[i][j + len + 1]--;     oky[j][i - len]++, oky[j][i + len + 1]--;     return 1;   }   int main() {     read(n), read(m);     for (register int i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (register int j = 1; j <= m; j++) {         if (s[j] ==  * )           g[i][j] = 1;         else           g[i][j] = 0;         sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + g[i][j];       }     }     for (register int i = 1; i <= n; i++) {       for (register int j = 1; j <= m; j++) {         if (g[i][j]) {           if (solve(i, j)) {             st[++tot] = Star(i, j, len);           }         }       }     }     for (register int i = 1; i <= n; i++) {       int tmp = 0;       for (register int j = 1; j <= m; j++) {         tmp += okx[i][j];         if (tmp) flag[i][j] = 1;       }     }     for (register int i = 1; i <= m; i++) {       int tmp = 0;       for (register int j = 1; j <= n; j++) {         tmp += oky[i][j];         if (tmp) flag[j][i] = 1;         if (g[j][i] && !flag[j][i]) {           puts( -1 );           return 0;         }       }     }     printf( %d n , tot);     for (register int i = 1; i <= tot; i++) {       printf( %d %d %d n , st[i].x, st[i].y, st[i].size);     }     return 0;   }   