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;
#define form2(i, a, b) for (int i = (a); i < (b); ++i)
#define ford2(i, a, b) for (int i = (a-1); i >= (b); --i)
#define form(i, n) form2(i, 0, n)
#define ford(i, n) ford2(i, n, 0)
#define chmax(x, v) x = max(x, (v))
#define chmin(x, v) x = min(x, (v))
#define fi first
#define se second
const long long BIG = 1000000000000000000LL;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
int nbBlocs;
const int maxPortes = 5005;
int bloc[maxPortes];
int blocToPorte[maxPortes];
void det(int i)
{
int rt = tryCombination(bloc);
assert(rt >= i);
bool w = (rt == i);
int l = 0, r = nbBlocs-1;
while (l < r) {
int m = (l+r+1) / 2;
form(w, m+1) {
if (blocToPorte[w] == -1) bloc[w] ^= 1;
}
bool rd = (tryCombination(bloc) == i);
bool change = rd^w;
if (change) { l=m; }
else { r=m-1; }
form(w, m+1) if (blocToPorte[w] == -1) bloc[w] ^= 1;
}
blocToPorte[l] = i;
bloc[l] ^= 1;
}
void exploreCave(int N)
{
fill_n(&blocToPorte[0], 5005, -1);
nbBlocs = N;
form(i, N) det(i);
answer(bloc, blocToPorte);
}
# | 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... |