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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
int corrState, l, r;
bool done[5005];
vector<int> switches;
void exploreCave(int N) {
for (int i=0; i < N; ++i) done[i] = false;
int S[N], D[N];
for (int i=0; i < N; ++i) {
switches.clear();
for (int j=0; j < N; ++i) if (!done[j]) switches.push_back(j);
for (int j=0; j < N-i; ++j) S[switches[j]] = 0;
corrState = (tryCombination(S) == i) ? 1 : 0;
for (int j=0; j < N-i; ++j) S[switches[j]] = corrState^1;
l = 0;
r = N-i-1;
while (l < r) {
int mid = (l+r)/2;
for (int j=l; j <= mid; ++j) S[switches[j]] = corrState;
int firstOpen = tryCombination(S);
for (int j=l; j <= mid; ++j) S[switches[j]] = corrState^1;
if (firstOpen == i) l = mid+1;
else r = mid;
}
done[l] = true;
S[l] = corrState;
D[l] = 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... |