Submission #211689

#TimeUsernameProblemLanguageResultExecution timeMemory
211689anonymousCave (IOI13_cave)C++14
100 / 100
1404 ms604 KiB
#include "cave.h"
#define MAXN 5005
void exploreCave(int N) {
    int S[MAXN], D[MAXN], B=12; //correct orientation of switch, connection of switch
    bool done[MAXN]={};
    for (int i=0; i<N; i++) {
        int ask[MAXN], mask=0, type = 0;
        for (int j=0; j<N; j++) {
            if (done[j]) {ask[j]=S[j];}
            else {ask[j]=0;}
        }
        if (tryCombination(ask) == i) {
            type = 1; //correct setting is 1 for next door
        }
        for (int j=0; j<=B; j++) {
            for (int k=0; k<N; k++) {
                if (!done[k]) {ask[k] = (k&(1<<j)) > 0;}
            }
            if (tryCombination(ask) != i) {
                mask += (1<<j);
            }
        }
        if (type == 1) {
            S[mask] = 1, D[mask] = i, done[mask] = true;
        } else {
            S[(2<<B)-1-mask] = 0, D[(2<<B)-1-mask] = i, done[(2<<B)-1-mask] = true;
        }
    }
    answer(S, D);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...