#define TEAM 0 /* Your team # here */ #define PROBLEM NUMBER /* The problem # here */ #include #include #include #include FILE *in=0; FILE *out=0; void solve_problem(); int debug = 0; /*-------------------------------------------------------*/ int main(int argc, char *argv[]) { char inputFilename[64]; char outputFilename[64]; int teamNumber = TEAM; int j; sprintf(inputFilename, "prob%d.dat", PROBLEM); sprintf(outputFilename,"prob%d.out", PROBLEM); /* Process the command line arguments. This can change the filenames and/or team number */ j=1; while (j 0) { usePlank[step] = j; stump[step][0] = row + plankLength[j]; stump[step][1] = col; return length; } plankAvailable[j] = TRUE; } if (row - plankLength[j] >= 0 && swamp[row - plankLength[j]][col] == '*') /* move possible */ { plankAvailable[j] = FALSE; length = nextPlank( step+1, row - plankLength[j], col); if (length > 0) { usePlank[step] = j; stump[step][0] = row - plankLength[j]; stump[step][1] = col; return length; } plankAvailable[j] = TRUE; } if (col + plankLength[j] < 10 && swamp[row][col + plankLength[j]] == '*') /* move possible */ { plankAvailable[j] = FALSE; length = nextPlank( step+1, row, col + plankLength[j]); if (length > 0) { usePlank[step] = j; stump[step][0] = row; stump[step][1] = col + plankLength[j]; return length; } plankAvailable[j] = TRUE; } if (col - plankLength[j] >= 0 && swamp[row][col - plankLength[j]] == '*') /* move possible */ { plankAvailable[j] = FALSE; length = nextPlank( step+1, row, col - plankLength[j]); if (length > 0) { usePlank[step] = j; stump[step][0] = row; stump[step][1] = col - plankLength[j]; return length; } plankAvailable[j] = TRUE; } } } return 0; } /*-------------------------------------------------------*/ void solve_problem() { int j, k; int numberSteps; /* Read the swamp definition */ for (j=0; j<10; j++) { for (k=0; k<10; k++) fscanf(in, "%c", &swamp[j][k]); fscanf(in, "\n"); } if (debug) { for (j=0; j<10; j++) { for (k=0; k<10; k++) printf("%c", swamp[j][k]); printf("\n"); } } while ( fscanf(in, "%d", &numberPlanks) != EOF) { for (j=0; j 0 ) { for (j=0; j