#include "cave.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 5e3+5;
int n;
int fix[N];
int ind,ans[N],p[N],cnt[N];
void exploreCave(int N) {
n = N;
int v[n];
for (int i = 0; i < n; i++) {
v[i] = 0;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (!fix[j]) v[j] = 0;
}
int c = tryCombination(v);
int need;
if (c == i) {
need = 1;
} else {
need = 0;
}
int l = 0; int r = n-1;
while (l <= r) {
int mid = (l+r)/2;
for (int j = 0; j < n; j++) {
if (fix[j]) continue;
v[j] = 1 - need;
}
for (int j = 0; j <= mid; j++) {
if (fix[j]) continue;
v[j] = need;
}
int nc = tryCombination(v);
if (nc == -1 || nc > i) {
ind = mid;
r = mid - 1;
} else {
l = mid + 1;
}
c = nc;
}
ans[i] = ind;
fix[ind] = 1;
p[ind] = need;
v[ind] = need;
}
int S[N],D[N];
for (int i = 0; i < n; i++) {
S[i] = v[i];
D[ans[i]] = i;
}
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... |