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"
const int MX=5005;
int known[MX], state[MX], doors[MX];
int prev,n;
void ask()
{
prev=tryCombination(state);
}
int find_key(int st,int en,int door)
{
if(st==en) return st;
int mid=(st+en)/2;
int curp=prev;
for(int i=st;i<=mid;i++)
{
if(!known[i]) state[i]^=1;
}
ask();
if((curp==door)^(prev==door)) // Key in [st,mid]
return find_key(st,mid,door);
return find_key(mid+1,en,door);
}
void exploreCave(int N) {
ask();
n=N;
for(int i=0;i<n;i++)
{
int key=find_key(0,n-1,i);
if(prev==i)
{
state[key]^=1;
ask();
}
known[key]=1;
doors[key]=i;
}
answer(state,doors);
}
# | 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... |