# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530049 | buidangnguyen05 | Cave (IOI13_cave) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* input
*/
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e3;
int n;
vector<int> done, state, que;
int query(int cnt) {
for (int i = 0; i < n; ++i) {
if (done[i]) que[i] = state[i];
else if (cnt) que[i] = 1;
else que[i] = 0;
if (!done[i] && cnt) --cnt;
}
return tryCombination(que);
}
void exploreCave(int _n) {
n = _n; done.resize(n); state.resize(n); que.resize(n);
int prev = query(0);
for (int i = 0; i < n; ++i) {
int L = 0, R = n - 1, pos = 0;
while (L <= R) {
int mid = (L + R) >> 1;
int cur = query(mid);
if ((prev == i && cur > i) || (prev != i && cur == i)) {
pos = mid;
R = mid - 1;
}
else L = mid + 1;
}
if (prev == i) state[pos] = 1;
done[pos] = i;
prev = query(0);
}
answer(state, done);
}