# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159597 | maximath_1 | Cave (IOI13_cave) | C++11 | 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;
#define all l, r
int s[5069], d[5069];
bool vis[5069];
void flipLever(int l, int r){
for(int i=l; i<=r; i++) s[i]=1-s[i];
}
int findLever(int door, int n){
int l=0, r=n-1;
if(tryCombination(s)!=door) flipLever(all);
while(l<r){
int md=(l+r)/2;
flipLever(l, md);
int tmp=tryCombination(s);
flipLever(l, md);
if(tmp!=door) r=md;
else l=md+1;
}
return l;
}
void exploreCave(int n){
for(int i=0; i<n; i++){
int lv=findLever(i, n);
s[lv]=1-s[lv];
d[lv]=i; vis[lv]=true;
}
answer(s, d);
}