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;
void exploreCave(int N) {
vector<int> done(N, 0);
int S[N], D[N];
for (int i = 0; i < N; i++) {
S[i] = 0;
}
for (int i = 0; i < N; i++) {
vector<int> v;
for (int j = 0; j < N; j++) {
if (!done[j]) {
v.push_back(j);
}
}
int cur[N];
copy(S, S + N, cur);
int op = (tryCombination(cur) == i);
int l = 0, r = (int) v.size() - 1;
while (l < r) {
int m = (l + r) / 2;
copy(S, S + N, cur);
for (int j = l; j <= m; j++) {
cur[v[j]] = op;
}
for (int j = m + 1; j <= r; j++) {
cur[v[j]] = !op;
}
if (tryCombination(cur) == i) {
l = m + 1;
} else {
r = m;
}
}
S[v[l]] = op;
D[v[l]] = i;
done[v[l]] = 1;
}
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... |