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 ask(x) tryCombination(x)
void exploreCave(int n) {
int S[n], D[n], a[n];
bool flag[n]; fill(flag, flag + n, false);
fill(a, a + n, 0); // query with a, answer with S
for (int i = 0; i < n; i++) {
bool f = false, ff = false;
int prev = ask(a);
if (prev == i) S[i] = 1, f = true;
else S[i] = 0, f = false;
int l = 0, r = n - 1;
while (l < r) {
int m = (l + r) >> 1;
for (int j = l; j <= m; j++) if (!flag[j]) a[j] = S[i];
// if seg of S[i] is closed, it's the other side
prev = ask(a);
if (prev == i) ff = true;
else ff = false;
for (int j = l; j <= m; j++) if (!flag[j]) a[j] = 0;
if (f != ff) r = m;
else l = m + 1;
}
flag[l] = true; D[l] = i; a[l] = S[i];
// cout << S[i] << " " << D[l] << " " << l << " " << "\n";
// for (int i = 0; i < n; i++) cout << a[i] << " ";
// cout << "\n";
}
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... |