# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238830 | michao | Cave (IOI13_cave) | C++14 | 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>
#include "cave.h"
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
void exploreCave(int n)
{
vi arr(n,-1);
vi pom=arr;
vi perm(n,-1);
int x=0;
for (int door=0;door<n;door++)
{
pom=arr;
int bit=1;
for (int i=0;i<n;i++) if (perm[i]!=-1)pom[i]=1;
int y=tryCombination(pom);
if (y<=x)bit^=1;
int ip=0,ik=n-1;
while (ip+1<ik)
{
int mid=(ip+ik)>>1;
pom=arr;
for (int i=0;i<=mid;i++)pom[i]=bit;
y=tryCombination(pom);
if (y>x)ik=mid;
else ip=mid;
}
perm[ip+1]=door,arr[ip+1]=bit;
x++;
}
answer(arr,perm);
}