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