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;
void exploreCave(int N) {
vector<int> switches;
for (int i = 0; i < N; ++i)
switches.push_back(i);
int correct[N]; int perm[N];
for (int i = 0; i < N; ++i)
correct[i] = 0;
int current = tryCombination(correct);
for (int i = 1; i <= N; ++i) {
if (current == i) {
for (int j : switches)
correct[j] = 1;
current = tryCombination(correct);
assert(current > i);
}
int l = 0, r = switches.size() - 1;
while (l < r) {
int mid = (l + r) >> 1;
for (int i = l; i <= mid; ++i)
correct[switches[i]] = 1 - correct[switches[i]];
int pos = tryCombination(correct);
for (int i = l; i <= mid; ++i)
correct[switches[i]] = 1 - correct[switches[i]];
if (pos == i) {
r = mid;
} else {
l = mid + 1;
}
}
perm[switches[l]] = i - 1;
switches.erase(switches.begin() + l);
}
answer(correct, perm);
}
# | 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... |