이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |