# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668052 | finn__ | 동굴 (IOI13_cave) | C++17 | 796 ms | 392 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.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int n)
{
if (n == 1)
{
int p = 0, comb = (int)(tryCombination({0}) == 0);
answer(&comb, &p);
}
int p[n], comb[n];
vector<int> x(n); // switches to be determined
for (size_t i = 0; i < n; i++)
x[i] = i;
for (size_t i = 0; i < n; i++)
{
// First determine wheter the next switch must be on or off.
for (size_t i = 0; i < n - i; i++)
comb[x[i]] = 0;
bool next_on = (tryCombination(comb) == i);
size_t a = 0, b = n - i - 1;
while (a < b)
{
size_t mid = (a + b) / 2;
for (size_t j = 0; j <= mid; j++)
comb[x[j]] = !next_on;
if (tryCombination(comb) == i)
b = mid;
else
a = mid + 1;
for (size_t j = 0; j <= mid; j++)
comb[x[j]] = next_on;
}
p[x[a]] = i;
comb[x[a]] = next_on;
x.erase(x.begin() + a);
}
answer(comb, p);
}
Compilation message (stderr)
# | 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... |