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"
void exploreCave(int N)
{
int s[N], d[N];
int vis[N] = {0};
for(int i = 0; i < N; i++)
{
if(vis[i]) continue;
int cur = 0;
int got = -1;
int tmp[N];
for(int i = 0; i < N; i++)
{
if(vis[i]) tmp[i] = s[i];
else tmp[i] = cur;
}
int p = tryCombination(tmp);
if(p>=i) cur = 0;
else cur = 1;
for(int i = 0; i < N; i++)
{
if(vis[i]) tmp[i] = s[i];
else tmp[i] = cur;
}
int lo = 0, hi = N-1;
while(lo<=hi)
{
int mid = (lo+hi)>>1;
for(int r = 0; r < N; r++)
{
if(r>=lo && r<=mid) continue;
if(vis[r]) continue;
tmp[r] = 1-cur;
}
p = tryCombination(tmp);
if(p>=i)
{
got = mid;
hi = mid-1;
}
else
{
for(int j = lo; j <= mid; j++) tmp[j] = 1-cur;
for(int j = mid+1; j <= hi; j++) tmp[j] = cur;
lo = mid+1;
}
}
s[i] = cur;
d[i] = got;
}
answer(s, d);
}
# | 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... |