# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648880 | Truitadepatates | Cave (IOI13_cave) | C++17 | 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 <bits/stdc++.h>
using namespace std;
#include "cave.h"
void exploreCave(int n) {
int S[n];
int D[n];
int Sol[n];
bool fet[n];
for (int i = 0; i < n; i++){
S[i] = 0;
D[i] = -1;
Sol[i] = -1;
fet[i] = false;
}
if (tryCombination(S) == -1){
for (int i = 0; i < n; i++){
S[i] = 1;
D[i] = tryCombination(S);
S[i] = 0;
}
}
else{
for (int i = 0; i < n; i++){
int hola;
if (trycombination(S) == i) hola = 1;
else hola = 0;
int l = 0, r = n-1;
while (l < r) {
int m = (l+r)/2;
for (int j = 0; j < n; j++) {
if (fet[j]) Sol[j] = S[j];
else Sol[j] = 0;
}
for (int j = l; j <= m; j++){
if (not fet[j]){
Sol[j] = 1;
}
}
if (hola == 1){
if (tryCombination(Sol) == i) l = mid+1;
else r = mid;
}
else{
if (tryCombination(Sol) == i) r = mid;
else l = mid+1;
}
}
S[m] = hola;
fet[m] = true;
D[m] = i;
}
}
answer(S, D);
}