# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
813189 | I_Love_EliskaM_ | Cave (IOI13_cave) | C++17 | 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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0; i<n; ++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define pi pair<int,int>
#define f first
#define s second
using ll = long long;
int ask(int q[]) {
return tryCombination(q);
}
void exploreCave(int n) {
int type[n], pos[n];
forn(it,n) {
int q[n];
forn(i,n) q[i]=0;
forn(i,it+1) q[pos[i]]=type[i];
int x=ask(q);
if (x > it) type[i]=0;
else type[i]=1;
int l=0, r=n-1;
while (l<r) {
int mid=(l+r)>>1;
int q[n];
forn(i,n) q[i]=type[i]^(i>mid);
forn(i,it+1) q[pos[i]]=type[i];
int x=ask(q);
if (x>it) r=mid;
else l=mid+1;
}
pos[i]=r;
}
answer(pos,type);
}