# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
821331 | annabeth9680 | 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;
const int MAXN = 5010;
bool vis[MAXN]; int S[MAXN],match[MAXN];
void exploreCave(int N){
for(int i = 0;i<N;++i){
if(tryCombination(S) == i){ //this means that it should be all 1's instead of 0's
for(int j = 0;j<N;++j){
if(!vis[j]) S[j] = !S[j];
}
}
int lo = 0, hi = N-1;
while(lo < hi){
int mid = (lo+hi)/2;
for(int j = lo;j<=mid;++j){
if(!vis[j]) S[j] = !S[j];
}
if(tryCombination(S) == i) r = mid;
else lo = mid+1;
for(int j = lo;j<=mid;++j){
if(!vis[j]) S[j] = !S[j];
}
}
vis[lo] = true;
match[lo] = i;
}
answer(S,match);
}