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 <iostream>
#include "cave.h"
using namespace std;
void exploreCave(int n)
{
///da 25pts
/*
int D[N],S[N];
for(int i=0;i<N;i++){ S[i]=0; }
if(tryCombination(S)==-1){
for(int i=0;i<N;i++){
S[i]=1;
D[i]=tryCombination(S);
S[i]=0;
}
}
else{
for(int i=0;i<N;i++){
D[i]=i;
if(tryCombination(S)==i) S[i]=1;
}
}
answer(S,D);
*/
bool nochange[n];
for(int i=0;i<n;i++){ nochange[i]=false; }
int dosw[n];
int onoff[n];
for(int i=0;i<n;i++){
int exp[n];
for(int j=0;j<n;j++){
if(nochange[j]) exp[j]=onoff[j];
else exp[j]=1;
}
int trycom=tryCombination(exp);
int good=0;
if(trycom==-1 or trycom>i){
good=1;
}
///ahora se viene lo chido binary
int iz=0,der=n-1;
while(iz<der){
int media=(iz+der)/2;
for(int j=iz;j<=media;j++){
if(nochange[j]) exp[j]=onoff[j];
else exp[j]=good;
}
for(int j=media;j<=der;j++){
if(nochange[j]) exp[j]=onoff[j];
else exp[j]=1-good;
}
trycom=tryCombination(exp);
if(trycom==-1 or trycom>i) der=media;
else iz=media+1;
}
nochange[iz]=true;
dosw[iz]=i;
onoff[iz]=good;
}
answer(onoff,dosw);
}
# | 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... |