vijos P1197 费解的开关 题解

#include 
#include 

#define STATUS 0
#define STEP 1

int queue[1000000][2];
int answer[1<<25];
int head = 0, tail = 0;

void addToQueue(int status, int step){
    queue[tail][STATUS] = status;
    queue[tail][STEP] = step;
    answer[status] = step;
    tail++;
}
int main(){
    char line[10];
    int numQuery, i, j, k, step, status;

    for(i=0; i<(1<<25); i++)
        answer[i] = -1;

    addToQueue((1<<25)-1, 0);  //all lights up
    while(head < tail){
        status = queue[head][STATUS];
        step = queue[head][STEP];
        if(step < 6){
            for(i=0; i<25; i++){
                k = status;

                // generate new status
                k ^= 1<

你可能感兴趣的:(vijos,题解)