#include #include #include #include #include FILE *in; int n=0,num=0; int a,b,c,i,j,k,l; char p[70][70]; int w,h; int d[20]; int dicenum; void eraseeye(int x,int y) { if( (x<0) || (x>=w) || (y<0) || (y>=h) ) return; if(p[x][y]!='X') return; p[x][y]='*'; eraseeye(x,y-1); eraseeye(x,y+1); eraseeye(x-1,y); eraseeye(x+1,y); } void erasedice(int x,int y) { if( (x<0) || (x>=w) || (y<0) || (y>=h) ) return; if(p[x][y]=='.') return; if(p[x][y]=='X') { eraseeye(x,y); d[dicenum]++; } p[x][y]='.'; erasedice(x,y-1); erasedice(x,y+1); erasedice(x-1,y); erasedice(x+1,y); } int cmpint(const void *xp,const void *yp) { int x=*(const int *)xp, y=*(const int *)yp; if(xy) return 1; return 0; } int main(){ in=fopen("dice.in","r"); while(fscanf(in,"%d%d ",&w,&h)&&(w!=0||h!=0)){ num++; dicenum=0; for(i=0;i<20;i++) d[i]=0; for (j=0;j