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;
void exploreCave(int n)
{
int D[n];
int S[n];
int lock[n];
for(int i = 0; i < n; i++)
{
D[i] = 0;
S[i] = 0;
lock[i] = 0;
}
if(n==1)
{
if(tryCombination(S)==-1) answer(S, D);
S[0] = 1;
answer(S, D);
}
for(int i = 0; i < n; i++)
{
int lo = 0, hi = n-1;
int last = -1, cur = -1, first = 0;
while(lo<hi)
{
if(!first)
{
last = tryCombination(S);
first = 1;
}
else last = cur;
int mid = (lo+hi)>>1;
for(int r = lo; r <= mid; r++)
{
if(!lock[r]) S[r] = 1-S[r];
}
cur = tryCombination(S);
if(cur==last || (cur!=i && last!=i)) lo = mid+1;
else hi = mid;
}
lock[lo] = 1;
D[lo] = i;
}
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... |