#include <bits/stdc++.h>
#include "cave.h"
#define TASK "cave"
#define INT_LIM (int) 2147483647
#define LL_LIM (long long) 9223372036854775807
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define ll long long
#define pii pair<int,int>
using namespace std;
///------------------------------------------///
void exploreCave(int n)
{
int s[n], d[n];
FOR(i, 0, n-1) s[i] = d[i] = -1;
FOR(i, 0, n-1)
{
int t[n];
FOR(j, 0, n-1)
{
if (s[j]!=-1) t[j] = s[j];
else t[j] = 0;
}
int val = tryCombination(t);
int l = 0, r = n-1, ret = -1;
while (l<=r)
{
int mid = (l+r)>>1;
FOR(j, 0, n-1) if (s[j]==-1)
{
if (j<=mid) t[j] = 1;
else t[j] = 0;
}
int val2 = tryCombination(t);
int control = (val==i)+(val2==i);
if (control==1)
{
ret = mid;
r = mid-1;
}
else l = mid+1;
}
// cout << ret << ' ' << val << endl;
d[ret] = i;
if (val==i) s[ret] = 1;
else s[ret] = 0;
}
answer(s,d);
}
# | 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... |