# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055586 | MrPavlito | 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.
void exploreCave(int N) {
int n = N;
int trenutnacomb[n];
int solved[n];
int rez[n];
for(int i=0; i<n; i++)trenutnacomb[i] = 0, solved[i] = 0, rez[i] = 0;
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)if(solved[j])trenutnacomb[j] = solved[j];
int t = tryCombination(trenutnacomb);
int l = 0;
int r = n-1;
while(l<r)
{
int mid = l+r >> 1;
for(int j=l; j<= mid; j++)if(!solved[j])trenutnacomb[j] ^= 1;
int p = tryCombination(trenutnacomb);
bool pomoc;
if(p == i && t == i)pomoc = true;
else if(p != i && t == i)pomoc = false;
else if(p == i && t !=i) pomoc = false;
else pomoc = true;
if(!pomoc)r = mid;
else l = mid+1;
t = p;
}
solved[l] = i;
rez[l] = trenutnacomb[l];
if(t == i)rez[l] = (trenutnacomb[l]^1);
}
}
//for(int i=0; i<n; i++)cout << trenutnacomb[i] << " ";cout << endl;
//for(int i=0; i<n; i++)cout << solved[i] << " ";cout << endl;
anwser(rez, solved);
}