#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
const int N = 5003;
int s[N], d[N];
int tryCombination(int S[]);
void answer(int S[], int D[]);
void exploreCave(int n) {
for (int i = 0; i < n; i++) d[i] = -1;
auto ok = [&](int l, int r, int i) {
for (int k = l; k <= r; k++) {
if (d[k] != -1) continue;
s[k] = 0;
}
int x = tryCombination(s);
for (int k = l; k <= r; k++) {
if (d[k] != -1) continue;
s[k] = 1;
}
int y = tryCombination(s);
return (x != y);
};
for (int i = 0; i < n; i++) {
int low = 0, high = n-1;
while (low < high) {
int mid = (low + high) / 2;
if (ok(low, mid, i))
high = mid;
else
low = mid+1;
}
d[i] = low;
s[i] = 0;
int x = tryCombination(s);
if (x == low)
s[i] = 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... |