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;
for (i=0; i<=n-1; i++)
{
if (d[i] == -1)
{
s[i] ^= 1;
cur1 = conv(tryCombination(s));
if (cur1<cur)
{
d[i] = cur1;
cnt++;
} else if (cur1>cur)
{
j = i;
d[i] = cur;
ncur = cur1;
cnt++;
}
s[i] ^= 1;
}
}
s[j] ^= 1;
}
answer(s, d);
}
Compilation message (stderr)
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:45:14: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | s[j] ^= 1;
| ~~~~~^~~~
# | 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... |