Enumeration Method
# include
# include
# include
using namespace STD; int ans; char map [10] [10]; int dir [8] [2] = {, 0,-, 0,-,-, 1, -1,-1,-1}; void find (int x, int y) {If (Map [x] [Y]! = '*') Return; int I; int sum = 0; for (I = 0; I <8; I ++) {int temp = 0; int Nx = X, NY = y; while (1) {Nx = dir [I] [0] + NX; ny = dir [I] [1] + ny; if (nx <0 | NX> = 8 | ny <0 | ny> = 8) break; If (Map [NX] [NY] = '*') break; If (Map [NX] [NY] = 'l') temp ++; If (Map [NX] [NY] = 'D ') {sum + = temp; break ;}}if (sum> ans) ans = sum;} int main () {int I, j, Count = 1; int T; cin> T; while (t --) {ans = 0; for (I = 0; I <8; I ++) CIN> map [I]; for (I = 0; I <8; I ++) for (j = 0; j <8; j ++) Find (I, j ); printf ("case % d: % d \ n", Count ++, ANS);} return 0 ;} /* 55 * D * lll * dl * LD ** ** lll **************************** **************************************** * ***** llllllll ******l ************************** L * ******* l ********* lllllll * 8000 */