#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vlld = vector<lld>;
// #define endl '\n'
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
#define fore(i,l,r) for(auto i=l;i<r;i++)
#define fo(i,n) fore(i,0,n)
#define forex(i,r,l) for(auto i=r; i>=l;i--)
#define ffo(i,n) forex(i,n-1,0)
bool cmin(ll &a, ll b) { if(b<a){a=b;return 1;}return 0; }
bool cmax(ll &a, ll b) { if(b>a){a=b;return 1;}return 0; }
void valid(ll in) { cout<<((in)?"YES\n":"NO\n"); }
ll lcm(ll a, ll b) { return (a/gcd(a,b))*b; }
ll gauss(ll n) { return (n*(n+1))/2; }
// ll tryCombination (int S[]) {
// fo (i, 4) cout << S[i] << ' ';
// cout << endl;
// ll ans;
// cin >> ans;
// return ans;
// }
void exploreCave(int n) {
int s[n]{}, d[n]{}, tos[n]{}, qs[n]{}, nqs[n]{}, alive[n];
fo (i, n) alive[i] = 1;
fo (i, n) {
fo (j, n) nqs[j] = qs[j] = 0;
fo (j, i) nqs[tos[j]] = qs[tos[j]] = s[tos[j]];
int idx = tryCombination(qs), w = 0;
if (idx == -1) idx = n;
if (idx == i) w = 1;
int l = 0, r = n-1-i;
while (l <= r) {
int m = (l+r)/2, c = 0;
fo (j, n) {
if(!alive[j]) continue;
c++;
if (c-1 <= m) nqs[j] = w;
else nqs[j] = (w^1);
}
idx = tryCombination(nqs);
if (idx == -1) idx = n;
if (idx > i) r = m-1;
else l = m+1;
}
int whswt = 0, c = 0;
fo (j, n) {
c += alive[j];
if (c-1 == l) {
whswt = j;
break;
}
}
tos[i] = whswt;
alive[tos[i]] = 0;
s[tos[i]] = w;
}
//fo (i, n) d[tos[i]] = i;
//fo (i, n) cout << s[i] << ' ';
//cout << endl;
//fo (i, n) cout << d[i] << ' ';
//cout << endl;
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... |