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 <iostream>
using namespace std;
int s[5005];
int rs[5005];
int cn[5005];
void exploreCave(int n)
{
int lg = 0;
while ((1<<lg) < n)
lg++;
// cout << n << " " << lg << "\n";
for (int i = 0; i < n; i++)
rs[i] = -1;
for (int tr = 0; tr < n; tr++)
{
// cout << "-> " << tr << "\n";
int ixn = 0;
for (int j = 0; j < lg; j++)
{
// cout << " ";
for (int i = 0; i < n; i++)
{
s[i] = (i&(1<<j) ? 1 : 0);
if (rs[i] != -1)
s[i] = rs[i];
// cout << s[i] << " ";
}
// cout << "\n";
int odg = tryCombination(s)-1;
if (odg == -2)
odg = n-1;
// cout << "\t" << odg << "\n";
if (odg >= tr)
{
// cout << "\ttest" << "\n";
ixn |= (1<<j);
}
}
int ix = 0;
for (int j = 0; j < lg; j++)
if (!(ixn & (1<<j)))
ix |= (1<<j);
for (int i = 0; i < n; i++)
{
s[i] = 0;
if (rs[i] != -1)
s[i] = rs[i];
}
if (ixn < n)
s[ixn] = 1;
if (ix < n && rs[ix] == -1)
s[ix] = 1;
int odg = tryCombination(s)-1;
if (odg == -2)
odg = n-1;
// cout << "-> " << tr << " <> " << odg << ", " << ixn << "\n";
if (odg >= tr)
{
// cout << ixn << " " << tr << "\n";
cn[ixn] = tr;
rs[ixn] = 1;
}
else
{
cn[ix] = tr;
rs[ix] = 0;
}
}
answer(rs, cn);
}
# | 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... |