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>
const int Nmax = 5005;
using namespace std;
int a[Nmax], ans[Nmax];
bool used[Nmax];
int eh(int x) { if(x == -1) return Nmax; return x; }
void exploreCave(int N)
{
int i, j, x;
vector<int> v;
for(i=0; i<N; ++i)
{
v.clear();
for(j=0; j<N; ++j)
if(!used[j]) v.push_back(j);
for(auto it : v) a[it] = 0;
if(eh(tryCombination(a)) > i) x = 0;
else x = 1;
int st, dr, mid;
st = 0; dr = v.size() - 1;
while(st < dr)
{
mid = (st+dr) / 2;
for(j=st; j<=mid; ++j) a[v[j]] = x;
for(j=mid+1; j<=dr; ++j) a[v[j]] = x ^ 1;
if(eh(tryCombination(a)) > i) dr = mid;
else st = mid+1;
}
st = v[st];
used[st] = 1;
a[st] = x;
ans[st] = i;
}
answer(a, 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... |