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;
bitset<5001> vit;
void exploreCave(int n) {
int* arr = new int[n];
int* cnt = new int[n];
function<void(int, int)> rev = [&](int s, int e) -> void {
for (int i = s; i <= e; i++) {
if (vit[i]) continue;
arr[i] = (arr[i] == 1) ? 0 : 1;
}
};
for (int i = 0; i < n; i++) {
int pos = 0;
int k = tryCombination(arr);
int lo = 0, hi = n - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
rev(lo, mid);
int w = tryCombination(arr);
//이미 문이 열려있음
if (k > i) {
if (w == i) hi = mid - 1;
else lo = mid + 1;
}
//이미 문이 닫혀있을 때
else {
if (w > i) hi = mid - 1;
else lo = mid + 1;
}
rev(lo, mid);
}
if (k <= i) arr[pos] = (arr[pos] == 1) ? 0 : 1;
cnt[i] = pos;
vit[pos] = true;
}
answer(arr, cnt);
}
# | 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... |