# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58068 | naderjemel | Cave (IOI13_cave) | C++14 | 467 ms | 640 KiB |
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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
int s[5000],ss[5000],d[5000];
void exploreCave(int N) {
for(int i=0;i<N;i++){
s[i]=0;
d[i]=-1;
}
bool done[5005];
memset(done,false,sizeof(done));
for(int i=0;i<N;i++){
int lo=0,hi=N-1;
int rs;
int r=tryCombination(s);
if(r==i){ // it opens with 1
while(lo<=hi){
int mid=(lo+hi)>>1;
for(int j=mid;j<N;j++) ss[j]=s[j];
for(int j=lo;j<=mid;j++){
if(done[j]) ss[j]=s[j];
else ss[j]=1;
}
int rr=tryCombination(ss);
if(rr==i){
lo=mid+1;
}
else{
hi=mid-1;
rs=mid;
}
}
d[rs]=i;
done[rs]=true;
s[rs]=1;
}
else{ // it opens with 0
while(lo<=hi){
int mid=(lo+hi)>>1;
for(int j=mid;j<N;j++) ss[j]=s[j];
for(int j=lo;j<=mid;j++){
if(done[j]) ss[j]=s[j];
else ss[j]=1;
}
int rr=tryCombination(ss);
if(rr==i){
hi=mid-1;
rs=mid;
}
else{
lo=mid+1;
}
}
d[rs]=i;
done[rs]=true;
s[rs]=0;
}
}
answer(s,d);
}
Compilation message (stderr)
# | 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... |