Submission #1002239

#TimeUsernameProblemLanguageResultExecution timeMemory
1002239toast12Cave (IOI13_cave)C++14
33 / 100
62 ms744 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

void exploreCave(int N) {
    int s[N], d[N];
    set<int> a;
    for (int i = 0; i < N; i++) {
        s[i] = -1;
        d[i] = -1;
        a.insert(i);
    }
    // iterate over all doors and find out which switch opens the ith door
    for (int i = 0; i < N; i++) {
        // find which switch unlocks door i
        for (auto it = a.begin(); it != a.end(); it++) {
            int j = *it;
            if (s[j] != -1)
                continue;
            // try setting the current switch to down position
            s[j] = 0;
            int x = tryCombination(s);
            if (x == i+1 || x == -1) {
                // the current switch unlocks the current door
                d[j] = i;
                break;
            }
            // try setting the switch to up position
            s[j] = 1;
            x = tryCombination(s);
            if (x == i+1 || x == -1) {
                d[j] = i;
                break;
            }
            s[j] = -1;
        }
    }
    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...