#include <bits/stdc++.h>
#include "cave.h"
#define PB push_back
#define ll long long
#define F first
#define S second
using namespace std;
void exploreCave(int N) {
int ceros[N];
int combinacioncorrecta[N];
int abrepuerta[N];
for(int i = 0 ; i < N ; i++){
ceros[i]=0;
combinacioncorrecta[i]=-1;
}
int good, bad;
for(int i = 0 ; i < N ; i ++){
for(int j = 0 ; j < N ; j ++){
if(combinacioncorrecta[j]!=-1)ceros[j]=combinacioncorrecta[j];
else ceros[j]=0;
}
if(tryCombination(ceros)>i){//está abierta
good=0, bad=1;
}else{
good=1, bad=0;
}
int li=0, ls = N-1, mid;
mid=(li+ls)/2;
while(mid!=li && li!=ls){
mid=(li+ls)/2;
for(int j = li ; j<= mid ; j++)if(combinacioncorrecta[j]==-1)ceros[j]=good;
for(int j = mid+1 ; j<= ls ; j++)if(combinacioncorrecta[j]==-1)ceros[j]=bad;
if(tryCombination(ceros)>i){
ls=mid;
}else{
li=mid+1;
}
}
combinacioncorrecta[li]=good;
abrepuerta[li]=i;
}
answer(combinacioncorrecta, abrepuerta);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
99 ms |
408 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
155 ms |
340 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
99 ms |
408 KB |
Answer is wrong |
2 |
Halted |
0 ms |
0 KB |
- |