이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |