#include <stdio.h>
#define DEBUG 0
#define TESTCASES 9
#define CLOCKS 9
#define MOVES 9
#define FOR(index, size) for ((index) = 0; (index) < (size); (index)++)
int initialState[CLOCKS];
int arrayOfMove[MOVES][CLOCKS] = { {3, 3, 0, 3, 3, 0, 0, 0, 0},
{3, 3, 3, 0, 0, 0, 0, 0, 0},
{0, 3, 3, 0, 3, 3, 0, 0, 0},
{3, 0, 0, 3, 0, 0, 3, 0, 0},
{0, 3, 0, 3, 3, 3, 0, 3, 0},
{0, 0, 3, 0, 0, 3, 0, 0, 3},
{0, 0, 0, 3, 3, 0, 3, 3, 0},
{0, 0, 0, 0, 0, 0, 3, 3, 3},
{0, 0, 0, 0, 3, 3, 0, 3, 3} };
int timesOfMove[MOVES];
int main(){
#if DEBUG
int testCase;
for (testCase = 1; testCase <= TESTCASES; testCase++){
char inputFileName[20] = "inputX.txt";
inputFileName[5] = '1' + (testCase - 1);
freopen(inputFileName, "r", stdin);
printf("\n#%d\n", testCase);
#endif
int clock;
FOR(clock, CLOCKS)
scanf("%d", &initialState[clock]);
int state;
FOR(timesOfMove[0], 4)
FOR(timesOfMove[1], 4)
FOR(timesOfMove[2], 4)
FOR(timesOfMove[3], 4)
FOR(timesOfMove[4], 4)
FOR(timesOfMove[5], 4)
FOR(timesOfMove[6], 4)
FOR(timesOfMove[7], 4)
FOR(timesOfMove[8], 4){
int fail = 0;
FOR(clock, CLOCKS){
state = initialState[clock];
int move;
FOR(move, MOVES)
state += arrayOfMove[move][clock] * timesOfMove[move];
if (state % 12 != 0){
fail = 1;
break;
}
}//end of FOR(clock, CLOCKS)
if (fail == 0){
int move;
FOR(move, MOVES){
int times = timesOfMove[move];
while (times > 0){
printf("%d%c", move + 1, move == MOVES - 1 && times == 1 ? '\n' : ' ');
times--;
}
}
}
}//end of FOR(timesOfMove[8], 4)
#if DEBUG
}
#endif
return 0;
}
USACO 1.4 The Clocks (暴力枚举)
最新推荐文章于 2024-06-29 11:50:17 发布