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 now[5010], where[5010], n;
bool ch[5010];
void rev(int a, int b){
for(int i=a; i<=b; i++)if(!ch[i])now[i]^=1;
}
int tryc(int S[]){
int tmp=tryCombination(now);
if(tmp==-1)return n;
return tmp;
}
int binsearch(int st, int fin, bool fl, int num){
if(st==fin)return st;
int mid=(st+fin)/2;
if(fl){
rev(st, mid);
if(tryc(now)!=num){
rev(st, mid);
return binsearch(st, mid, fl, num);
}
rev(st, mid);
return binsearch(mid+1, fin, fl, num);
}
else{
rev(st, mid);
if(tryc(now)==num){
rev(st, mid);
return binsearch(st, mid, fl, num);
}
rev(st, mid);
return binsearch(mid+1, fin, fl, num);
}
}
void exploreCave(int _n){
n=_n;
for(int i=0; i<n; i++){
int temp=tryc(now);
int but=binsearch(0, n-1, temp==i, i);
if(temp==i){
where[but]=i;
rev(but, but);
ch[but]=true;
}
else{
where[but]=i;
ch[but]=true;
}
}
answer(now, where);
}
# | 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... |