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<bits/stdc++.h>
#include "cave.h"
const int nmax=5e3+42;
int which[nmax];
int sign[nmax];
int now[nmax];
int active[nmax],sz=0;
void exploreCave(int N)
{
memset(which,-1,sizeof(which));
for(int i=0;i<N;i++)//find the i-th
{
for(int j=0;j<N;j++)
if(which[j]!=-1)now[which[j]]=sign[j];
else
{
now[j]=0;
sz++;
active[sz]=j;
}
int ans=tryCombination(now);
bool sign_now;
if(ans==-1||ans>i)sign_now=0;
else sign_now=1;
while(sz>1)
{
int mx=sz/2,pos=1;
for(int j=0;j<N;j++)
if(which[j]!=-1)now[which[j]]=sign[j];
else
{
now[j]=0;
if(pos<mx&&active[pos]==j)now[j]=sign_now,pos++;
else now[j]=!sign_now;
}
int ans=tryCombination(now);
if(ans==-1||ans>i)sz=mx;
else
{
for(int j=mx+1;j<=sz;j++)
active[j-mx]=active[j];
sz=sz-mx;
}
}
sign[active[1]]=sign_now;
which[active[1]]=i;
}
answer(sign,which);
}
# | 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... |