#include #include ifstream f("dice.in"); char array[52][51]; int replace(char from, char to, int start, int end) { if(array[start][end]==from) { array[start][end]=to ; return (1+ replace(from, to, start-1, end)+ replace(from, to, start+1, end)+ replace(from, to, start, end-1)+ replace(from, to, start, end+1)); } return 0; }; int replaceStart(int start, int end) { if(array[start][end]=='X') { array[start][end]='B' ; return 1+ replaceStart(start-1, end)+ replaceStart(start+1, end)+ replaceStart(start, end-1)+ replaceStart(start, end+1); } if(array[start][end]=='*') { array[start][end]='A' ; return 1+ replaceStart(start-1, end)+ replaceStart(start+1, end)+ replaceStart(start, end-1)+ replaceStart(start, end+1); } return 0; }; int main() { int xsize, ysize; int m=0; int result[6]; f >> xsize; f >> ysize; while(xsize+ysize!=0) { int i; for(i=0; i> array[i+1]; array[i+1][xsize+1]='.'; array[i+1][50]='.'; } for(i=0; i<51; i++) { array[0][i]='.'; array[ysize+1][i]='.'; } int count = 0; int j,k,l; for(i=0; i<6; i++) result[i]=0; for(i=0; i<=xsize; i++) for(j=1; j<=ysize; j++) if(replaceStart(j,i)!=0) { // cout << "connected found " << endl; count = -1; for(k=0; k<=xsize; k++) for(l=1; l<=ysize; l++) if(replace('B','C',l,k) != 0) count ++; result[count]++; } m++; cout << "Throw " << m << endl;; for(i=0; i<6; i++) { for(j=0; j> xsize; f >> ysize; // cout << xsize << " " << ysize << endl; } }