#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);
if (k == -1) continue;
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
88 ms |
484 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
364 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
88 ms |
484 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |