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 <bits/stdc++.h>
using namespace std;
const int nmax = 5000;
bool viz[nmax + 1];
int v[nmax + 1];
int s[nmax + 1], d[nmax + 1];
void divide (int x, int y, int ind, int lst) {
if (x == y) {
s[x] = (lst > ind ? v[x] : 1 - v[x]);
d[x] = ind;
viz[x] = 1;
return ;
}
int mij = (x + y) / 2;
for (int i = x; i <= mij; ++ i)
if (viz[i] == 0)
v[i] ^= 1;
int val = tryCombination(v);
if (val == -1)
val = nmax + 1;
if ((val > ind && lst <= ind) || (val <= ind && lst > ind)) {
divide(x, mij, ind, val);
} else {
for (int i = x; i <= mij; ++ i)
if (viz[i] == 0)
v[i] ^= 1;
divide(mij + 1, y, ind, lst);
}
}
void exploreCave(int N) {
for (int i = 0; i < N; ++ i) {
for (int j = 0; j < i; ++ j)
v[j] = s[j];
divide(0, N - 1, i, tryCombination(v));
}
answer(s, d);
}
# | 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... |