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) {
vector<int> rest(N);
iota(rest.begin(), rest.end(), 0);
int S[N], D[N];
for (int i = 0; i < N; ++i) {
S[i] = 0;
}
for (int i = 0; i < N; ++i) {
int start = tryCombination(S);
if (start == -1) { start = N; }
int left = 0, right = rest.size();
while (right - left > 1) {
int mid = left + (right - left) / 2;
for (int j = left; j < mid; ++j) {
S[rest[j]] = 1;
}
int closed = tryCombination(S);
if (closed == -1) { closed = N; }
for (int j = left; j < mid; ++j) {
S[rest[j]] = 0;
}
if ((start == i && closed > i) || (start > i && closed == i)) {
right = mid;
} else {
left = mid;
}
}
D[rest[left]] = i;
if (start == i) {
S[rest[left]] = 1;
} else {
S[rest[left]] = 0;
}
swap(rest[left], rest.back());
rest.pop_back();
}
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... |