#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
int s[6000];
int d[6000];
int used[6000];
int last, n;
int First;
bool check(int l, int r){
int i;
for(i=l; i <= r; i++){
if(used[i] == 1)continue;
s[i] = 1;
}
int temp1 = tryCombination(s);
for(i=l; i <= r; i++){
if(used[i] == 1)continue;
s[i] = 0;
}
int temp2 = tryCombination(s);
if(temp1 == -1)temp1 = n;
if(temp2 == -1)temp1 = n;
if(temp1 >= last){
First = 1;
return true;
}else if(temp2 >= last){
First = 0;
return true;
}else {
return false;
}
}
void exploreCave(int N) {
n = N;
for(int door = 0; door < n; door ++ ){
last = door+1;
int l=0, r=n-1;
while(l+1 < r){
int mid = (l+r)/2;
if(check(l, mid)){
r = mid;
}else {
l = mid;
}
}
d[l] = door;
s[l] = First;
used[l] = 1;
}
answer(s, d);
}
/*
4
1 1 1 0
3 1 0 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
504 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
33 ms |
384 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
27 ms |
504 KB |
too much calls on tryCombination() |
2 |
Halted |
0 ms |
0 KB |
- |