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 <iostream>
#include "cave.h"
using namespace std;
const int N = 5005;
int s[N];
int fixat[N];
int button[N];
int door[N];
int S[N], D[N];
int nn;
void exploreCave(int n)
{
int i;
nn = n;
for (int curr = 0; curr < n; curr++)
{
int key = 1;
for (i = 0; i < n; i++)
{
if (fixat[i])
s[i] = fixat[i] - 1;
else
s[i] = 1;
}
if (tryCombination(s) == curr)
{
for (i = 0; i < n; i++)
{
if (fixat[i])
s[i] = fixat[i] - 1;
else
s[i] = 0;
}
key = 0;
}
int st = 0, dr = n - 1;
while(st <= dr)
{
if (st == dr)
{
fixat[st] = s[st] + 1;
button[st] = s[st];
door[st] = curr;
break;
}
int mid = (st + dr) / 2;
for (i = st; i <= mid; i++)
if (!fixat[i])
s[i] = 1 - key;
if (tryCombination(s) == curr)
{
for (i = st; i <= mid; i++)
if (!fixat[i])
s[i] = key;
dr = mid;
}
else
st = mid + 1;
}
}
answer(button, door);
}
# | 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... |