#include #include /** * 0 empty * 1 die * 2 pix * 3fpix */ char p[500][500]; char r[500*250]; int rc; int cmp(const void *pa, const void *pb) { return *((char *)pa) - *((char *)pb); } int w, h; void dot(int x, int y) { char s[500]; int i; int xl, xr; int xlm, xrm; int er = 0; int proc; int some; /*init*/ xl = xr = x; while (xl >= 0 && p[xl][y] == 2) xl--; xl++; while (xr = 0 && (i >= xl || proc)) { if (s[i]) { proc = 1; goto sc; } if (proc) { if (p[i][y] == 2) s[i] = 1; else proc = 0; } sc: i--; } xl = i + 1; } else er = 1; /* test on row */ xlm = w; xrm = -1; for (i = xl; i < xr; i++) { if (s[i]) { if (i < xlm) xlm = i; if (i > xrm) xrm = i; } p[i][y] = 1; } xl = xlm; xr = xrm + 1; y++; if (y == h) break; some = 0; for (i = xl; i < xr; i++) { if (s[i] && p[i][y] == 2) { some = 1; } else s[i] = 0; } } } void dice(int x, int y) { char s[500]; int i; int xl, xr; int xlm, xrm; int dd = 0; int er = 0; int proc; int some; /*init*/ xl = xr = x; while (xl >= 0 && p[xl][y]) xl--; xl++; while (xr = 0 && (i >= xl || proc)) { if (s[i]) { proc = 1; goto sc; } if (proc) { if (p[i][y]) s[i] = 1; else proc = 0; } sc: i--; } xl = i + 1; } else er = 1; /* test on row */ xlm = w; xrm = -1; for (i = xl; i < xr; i++) { if (s[i]) { if (i < xlm) xlm = i; if (i > xrm) xrm = i; if (p[i][y] == 2) { /*printf("found dot start at %d %d\n",i,y);*/ dot(i,y); dd++; } } p[i][y] = 0; } xl = xlm; xr = xrm + 1; y++; if (y == h) break; some = 0; for (i = xl; i < xr; i++) { if (s[i] && p[i][y]) { some = 1; } else s[i] = 0; } } /* printf("dd = %d\n",dd);*/ r[rc++] = dd; } void pr(void) { int i, j; for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { if (p[i][j] == 1) putchar('*'); else if (p[i][j] == 2) putchar('X'); else putchar('.'); } putchar('\n'); } putchar('\n'); } int main(void) { int c, i, j; int dii; while (1) { scanf("%d %d",&w,&h); /*printf("%d %d\n",w,h);*/ if (w == 0 && h == 0) break; rc = 0; while (getchar() != '\n'); for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { c = getchar(); if (c == '.') c = 0; else if (c == '*') c = 1; else c = 2; p[i][j] = c; } getchar(); } /*pr();*/ dii = 0; for (j = 0; j < h; j++) { for (i = 0; i < w; i++) { if (p[i][j]) { dii++; dice(i,j); /* printf("after %d dice:\n",dii); pr();*/ } } } /* printf("dice = %d\n",dii);*/ qsort(r,rc,sizeof(r[0]),cmp); printf("Throw:"); for (i = 0; i < rc; i++) printf(" %d",r[i]); putchar('\n'); } return 0; }