# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648881 | 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.
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 = m+1;
else r = m;
}
else{
if (tryCombination(Sol) == i) r = m;
else l = m+1;
}
}
S[m] = hola;
fet[m] = true;
D[m] = i;
}
}
answer(S, D);
}