This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |