#include #include #include #include #include int h,w,dataset,i; char map[100][100]; void favoriteGrove() { int a,b,c,d; int e,f,g,hl; int grooveMax=0; int thisGroove; int B=0, C=0, F=0, M=0, O=0; int count[6] = {0,0,0,0,0,0}; char names[6][40] = {"Birches: ","Chesnuts: ","Elms: ","Firs: ","Maples: ","Oaks: "}; int x,y,temp; char tempN[40]; int values[26]; values['B'-'A'] = -5; values['C'-'A'] = 6; values['E'-'A'] = 3; values['F'-'A'] = -2; values['M'-'A'] = 1; values['O'-'A'] = 2; cout << "Data set " << i+1 << ": "; for(a=0; a=a) for(d=0; d=b) { thisGroove=0; for(x=a; x<=c; x++) for(y=b; y<=d; y++) if(map[y][x]!='-') thisGroove += values[map[y][x]-'A']; if(thisGroove>grooveMax) { grooveMax = thisGroove; e=a+1; f=b+1; g=c+1; hl=d+1; } } if(grooveMax>0) { cout << "grove (" << f << ", " << e << ") (" << hl << ", " << g << ") has quality " << grooveMax << endl; } else cout << "no grove has a positive score" << endl; cout << endl; } void main() { int j; cin >> dataset; for(i=0; i> h >> w; for(j=0; j> map[j]; favoriteGrove(); } }