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"
using namespace std;
int s[5069], d[5069], invd[5069], cur, cnt, cur1, ncur;
int conv(int x)
{
if (x == -1) return 5001;
return x;
}
void exploreCave(int n)
{
int i, j;
//mulai dari 000000
//d[i] --> switch i door apa
//invd[i] --> door i switch apa
for (i=0; i<=n-1; i++) s[i] = 0;
for (i=0; i<=n-1; i++) d[i] = -1;
ncur = conv(tryCombination(s));
for (cnt=0; cnt<n;)
{
cur = ncur;
// printf("cur = %d\n", cur);
j = -1;
for (i=0; i<=n-1; i++)
{
if (d[i] == -1)
{
s[i] ^= 1;
cur1 = conv(tryCombination(s));
// printf("s[%d] = %d cur1 = %d\n", i, s[i], cur1);
if (cur1<cur)
{
d[i] = cur1;
cnt++;
} else if (cur1>cur)
{
j = i;
d[i] = cur;
ncur = cur1;
cnt++;
// printf("j = %d\n", j);
}
s[i] ^= 1;
}
}
if (j != -1) s[j] ^= 1;
}
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... |