# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
649916 | Pablo_No | 동굴 (IOI13_cave) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
const int N = 5005;
const int B = 13;
int q[N];
int cpos[N];
int ord[N];
void exploreCave(int N) {
for(int i = 0; i < N; i++)
{
cpos[i] = -1;
}
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
{
q[j] = 0;
if(cpos[j] != -1)
q[j] = cpos[j];
}
int an = tryCombination(q);
cpos[i] = 1;
if(an > i)
cpos[i] = 0;
int cp = cpos[i];
int idx = 0;
for(int k = 0; k < B; k++)
{
for(int j = 0; j < N; j++)
{
q[j] = 1-cp;
if(cpos[j] != -1)
q[j] = cpos[j];
else if((j & (1 << k)) && ((j | ((1 << k)-1)) == idx))
q[i] = cp;
}
int anx = tryCombination(q);
if(anx > i)
idx += (1 << k);
}
ord[i] = idx;
}
answer(cpos, ord);
}