# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
655093 | angelo_torres | 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>
#include "cave.h"
using namespace std;
void exploreCave(int N) {
vector<int> S,D;
for(int i = 0; i < N; ++i){
vector<int> s(N);
for(auto &it : s) it = 0;
bool fl = (i == tryCombination(s));
int l = 0, r = N-1;
while(r != l){
int md = (l+r)>>1;
int kl = l, kr = md;
for(int j = l; j <= md; ++j) s[j] = 1-s[j];
bool gl = (i == tryCombination(s));
if(fl == gl) l = md+1;
else r = md;
for(int j = kl; j <= kr; ++j) s[j] = 1-s[j];
}
if(fl) S[l] = 1-s[l];
else S[l] = s[l];
D[l] = i;
}
answer(S,D);
}