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;
int ans[5005];
int S[5005];
int W[5005];
void exploreCave(int N) {
memset(ans, -1, sizeof ans);
vector<int> inSet;
for(int i = 0; i < N; i++)
inSet.push_back(i);
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++)if(ans[j] == -1)S[j] = 0;
else S[j] = ans[j];
int x = tryCombination(S);
if(x == -1)x = N;
bool f = (x <= i);
///find which switch is it
int lo = 0, hi = N - 1 - i;
while(lo < hi){
int md = lo + (hi - lo) / 2;
int cnt = 0;
for(int j = 0; j < N; j++){
if(ans[j] != -1)S[j] = ans[j];
else {
S[j] = (f ^ (cnt > md));
cnt++;
}
}
int x = tryCombination(S);
if(x == -1)x = N;
if(x > i)
hi = md;
else
lo = md + 1;
}
ans[lo] = f;
W[i] = lo;
}
answer(S,W);
}
# | 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... |