# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55670 | leejseo | Cave (IOI13_cave) | C++98 | 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.
#include "cave.h"
#include <vector>
using namespace std;
vector<int> L;
int S[5001], D[5001];
bool DONE[5001];
int binary(int s, int e, int i, int prev){
if (s == e) return s;
int mid = (s+e) >> 1;
for (int i=s; i<=mid; i++) S[L[i]] ^= 1;
int res = tryCombination(S);
if ((res == i) == (prev == i)) return binary(mid+1, e, i, res);
return binary(s, mid, i, res);
}
void exploreCave(int N) {
//what is cooected to 0?
for (int i=0; i<N; i++){
L.clear();
for (int j=0; j<N; j++){
if (!DONE[j]) L.push_back(j);
}
int m = j.size();
for (int j=0; j<m; j++) S[L[j]] = 0;
int prev = tryCombination(S);
int res = L[binary(s, e, i, prev)];
D[res] = i;
if (tryCombination(S) > i) S[res] ^= 1;
DONE[res] = 1;
}
}