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;
void exploreCave(int n) {
//determine first switch
int arr[n];
memset(arr,0,sizeof(arr));
int visited[n];
memset(visited,0,sizeof(visited));
int ans[n];
for(int x=0;x<n;x++){
for(int y=0;y<n;y++){
if(!visited[y]) arr[y]=0;
}
int hold=tryCombination(arr);
if(hold==-1) hold=n;
bool amos=false;
if(hold<=x) amos=true;
int l=0;
int r=n-1;
int best=l;
int mid;
while(l<=r){
mid=(l+r)/2;
for(int y=0;y<n;y++){
if(y<=mid&&!visited[y]){
arr[y]=!amos;
}
else if(!visited[y]) arr[y]=amos;
}
int hold2=tryCombination(arr);
if(hold2==-1) hold2=n;
if(hold2<=x){
best=mid;
r=mid-1;
}
else l=mid+1;
}
visited[best]=true;
arr[best]=!amos;
ans[x]=best;
}
answer(arr,ans);
}
# | 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... |