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 <bits/stdc++.h>
#include "cave.h"
using namespace std;
int s [5004];
int res [5004];
bool activos [5004];
int ans [5004];
int busqueda (bool esuno, int inde, int n){
int izq=0, der=n-1;
int mitad;
int rep=0;
int master;
while(izq<=der){
mitad=(izq+der)/2;
if(esuno)master=0;
else master=1;
for(int i=0; i<=mitad; i++){
if(activos[i])
{
s[i]=res[i];
}
else{
s[i]=master;
}
}
if(esuno)master=1;
else master=0;
for(int i=mitad+1; i<n; i++){
if(res[i]){
s[i]=res[i];
}
else{
s[i]=master;
}
}
int p = tryCombination(s);
if(p>=inde or p==-1){
der=mitad-1;
rep=mitad;
}
else {
izq=mitad+1;
}
}
return rep;
}
void exploreCave(int N) {
int ll;
for(int i=0; i<N; i++){
res[i]=false;
}
for(int j=1; j<=N; j++){
int master=1;
for(int i=0; i<N; i++){
if(activos[i]){
s[i]=res[i];
}
else{
s[i]=master;
}
}
ll=tryCombination(s);
int des;
int a;
if(ll>=j or ll==-1){
des= busqueda(true,j,N);
a=1;
}
else {
des=busqueda(false,j,N);
a=0;
}
activos [des]=true;
res[des]=a;
ans[j]=des;
}
answer(res, ans);
// int tryCombination(int S[]);
//void answer(int S[], int D[]);
//void exploreCave(int N);
}
# | 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... |