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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 2;
int f[MAXN], s[MAXN], ar[MAXN], pos[MAXN], used[MAXN];
void exploreCave(int N) {
for(int i = 0; i < N; i ++){
for(int j = 0; j < N; j ++)
ar[j] = 0;
for(int j = 0; j < i; j ++){
ar[ pos[j] ] = f[ pos[j] ];
}
int ret = tryCombination(ar);
vector <int> v;
for(int j = 0; j < N; j ++){
if(!used[j])
v.push_back(j);
}
int correct = 0;
if(ret == i)
correct = 1;
int lo = 0, hi = (int)v.size() - 1;
while(lo <= hi){
int md = (lo + hi) >> 1;
if(!correct){
for(int j = md + 1; j < (int)v.size(); j ++)
ar[ v[j] ] = 0;
for(int j = 0; j <= md; j ++)
ar[ v[j] ] = 1;
} else {
for(int j = md + 1; j < (int)v.size(); j ++)
ar[ v[j] ] = 1;
for(int j = 0; j <= md; j ++)
ar[ v[j] ] = 0;
}
ret = tryCombination(ar);
if(ret == i){
hi = md - 1;
} else {
lo = md + 1;
}
}
lo = v[hi + 1];
f[lo] = correct;
s[lo] = i;
used[lo] = 1;
pos[i] = lo;
}
answer(f, s);
}
# | 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... |