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 point[5010];
bool ch[5010];
int p[5010], n;
int binopen(int st, int fin, int num){
if(st==fin)return st;
int mid=(st+fin)/2;
for(int i=st; i<=mid; i++)
if(!ch[i])p[i]=(p[i]+1)%2;
int t=tryCombination(p);
if(t==-1)t=n;
for(int i=st; i<=mid; i++)
if(!ch[i])p[i]=(p[i]+1)%2;
if(t==num)return binopen(st, mid, num);
return binopen(mid+1, fin, num);
}
int binclose(int st, int fin, int num){
if(st==fin)return st;
int mid=(st+fin)/2;
for(int i=st; i<=mid; i++)
if(!ch[i])p[i]=(p[i]+1)%2;
int t=tryCombination(p);
for(int i=st; i<=mid; i++)
if(!ch[i])p[i]=(p[i]+1)%2;
if(t>num)return binclose(st, mid, num);
return binclose(mid+1, fin, num);
}
void exploreCave(int N){
n=N;
for(int i=0; i<n; i++){
int temp=tryCombination(p);
if(temp==i){
int num=binclose(0, n-1, i);
point[num]=i;
ch[num]=true;
p[i]=(p[i]+1)%2;
}
else{
int num=binopen(0, n-1, i);
point[num]=i;
ch[num]=true;
}
}
answer(point, p);
}
# | 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... |