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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
bool vis[MAXN]; //save for all switches if we set them already
int S[MAXN], ans[MAXN];
void exploreCave(int N){
//memset
for(int i = 0;i<N;++i){
if(tryCombination(S) == i){
for(int j = 0;j<N;++j){
if(!vis[j]) S[j] = 1-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] = 1-S[j];
}
if(tryCombination(S) == i) hi = mid;
else lo = mid+1;
for(int j = lo;j<=mid;++j){
if(!vis[j]) S[j] = 1-S[j];
}
}
vis[lo] = true;
ans[lo] = i;
}
answer(S,ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |