# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647935 | TrashCoder007 | 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;
void exploreCave(int n)
{
int a[n];
int id [n];
for (int i = 0; i < n; i++) id[i] = -1;
for (int i = 0; i < n; i++){
int val = tryCombination(a);
int k = 0; //abierta con 0
if (val == i) k = 1; //abierta con 1
int ini = 0, fin = n;
while(ini < fin){
int pos [n];
int m = (ini + fin) / 2;
for (int j = 0; j < n; j++){
if (j >= ini && j <= m && id[j] == -1){
pos[j] = 1 - k;
}else if (id[j] != -1){
pos[j] = a[j];
}else{
pos[j] = k;
}
}
int res = tryCombination(pos);
if ((res == ini && k) || (res != ini && !k)){
ini = m + 1;
}else{
fin = m;
}
}
id[ini - 1] = i;
a[ini - 1] = k;
}
answer(a, id);
}