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"
const int N=5005;
using namespace std;
void SW(int in[],int dn[],int ps){
for(int i=0;i<ps;i++){
if(dn[i]==0){
in[i]=1-in[i];
}
}
}
void exploreCave(int N){
int in[N],ns[N],dn[N];
for(int i=0;i<N;i++)in[i]=ns[i]=dn[i]=0;
for(int i=0;i<N;i++){
int cur=tryCombination(in);
if(cur>=i){
int l=0,r=N-1,ans=-1;
while(l<=r){
int m=(l+r)/2;
SW(in,dn,m);
if(tryCombination(in)<i){
ans=m;
l=m+1;
}else{
r=m-1;
}
SW(in,dn,m);
}
dn[ans]=1;
ns[i]=ans;
}else{
int l=0,r=N-1,ans=-1;
while(l<=r){
int m=(l+r)/2;
SW(in,dn,m);
if(tryCombination(in)>=i){
ans=m;
l=m+1;
}else{
r=m-1;
}
SW(in,dn,m);
}
dn[ans]=1;
ns[i]=ans;
in[ans]=1;
}
}
answer(in,ns);
}
# | 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... |