#include "cave.h"
#include <bits/stdc++.h>
//#define respagold ios_base::sync_with_stdio(0), cin.tie(0);
//#define int long long
#define ll long long
#define int2 __int128_t
#define FOR( i, x, n, d ) for( int i = x; i <= n; i += d )
#define FORR( i, x, n, d ) for( int i = x; i >= n; i -= d )
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define pii pair <int, int>
using namespace std;
const int N = 2e3 + 12;
const int mod = 1e9 + 7;
const ll inf = 2e18;
int n, m, x, y, z;
vector <int> v, ost, ans;
int ask( vector <int> v )
{
int S[n];
FOR( i, 0, n - 1, 1 ) S[i] = v[i];
return tryCombination(S);
}
void rec( int l, int r, int i, int x )
{
if( l == r )
{
v[ost[l]] = x; y = ost[l];
ost.erase(ost.begin() + l);
return;
}
int md = l + r >> 1, tol;
FOR( i, l, md, 1 ) v[ost[i]] = x;
tol = ask(v);
FOR( i, l, md, 1 ) v[ost[i]] = x ^ 1;
if( tol > i || tol == -1 ) rec(l, md, i, x);
else rec(md + 1, r, i, x);
}
void exploreCave( int N )
{
n = N;
FOR( i, 0, n - 1, 1 ) v.pb(0), ost.pb(i), ans.pb(0);
FOR( i, 0, n - 1, 1 )
{
int nw = ask(v);
if( nw > i || nw == -1 ) x = 0;
else x = 1;
for( auto j : ost ) v[j] = x ^ 1;
rec(0, sz(ost) - 1, i, x);
ans[y] = i;
for( auto j : ost ) v[j] = 0;
}
int S1[n], S2[n];
FOR( i, 0, n - 1, 1 )
{
S1[i] = v[i];
S2[i] = ans[i];
}
answer(S1, S2);
}
# | 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... |