#include "cave.h"
#include <vector>
#include <stdlib.h>
#include <cassert>
void exploreCave(int N) {
int* comb = (int*)calloc(N, sizeof(int));
int* fixed = (int*)calloc(N, sizeof(int));
int cnt = 0;
while (cnt < N) {
int t = tryCombination(comb);
if (t == -1) t = N;
assert(t >= cnt);
if (t > cnt) {
int i = 0;
while (t > cnt) {
if (fixed[i]) {++i; continue;}
comb[i] ^= 1;
t = tryCombination(comb);
if (t == -1) t = N;
++i;
}
--i;
++cnt;
fixed[i] = cnt;
comb[i] ^= 1;
} else {
int i = 0;
while (t == cnt) {
if (fixed[i]) {++i; continue;}
comb[i] ^= 1;
t = tryCombination(comb);
if (t == -1) t = N;
++i;
}
--i;
++cnt;
fixed[i] = cnt;
}
}
for (int i = 0; i < N; ++i) {
--fixed[i];
}
answer(comb, fixed);
}
# | 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... |