#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
int a[50000], us[50000];
int ans1[50000], ans2[50000];
void exploreCave(int n) {
//cout << n << '\n';
auto fp = [&](int l, int r) {
for(int i = l; i <= r; i ++ ) {
if(us[i])continue;
a[i] ^= 1;
};
};
int t = 0;
function<void(int,int)> f = [&](int l, int r) {
//cout << l << ' ' << r << '\n';
//for(int j = 0; j < n; j ++ ) cout << a[j] << ' ';
//cout << '\n';
if(l == r) {
//cout << ": " << t << ' ' << a[l] << '\n';
ans1[l] = a[l];
us[l] = 1;
ans2[l] = t++;
return;
};
int m = (l + r) >> 1;
fp(l, m);
if(tryCombination(a) == t) {
fp(l,m);
f(l,m);
return;
};
f(m+1, r);
};
for(int i = 0; i < n; i ++ ) {
int x = tryCombination(a);
//cout << a[0] << ' '<< a[1] << ' ' << a[2] << ' ' << a[3] << '\n';
//cout << x << '\n';
if(x == t) fp(0,n-1);
f(0, n-1);
//for(int j = 0; j < n; j ++ ) cout << a[j] << ' ';
//cout << '\n';
};
//for(int i : ans1) cout << i << '\n';
//cout << 1 << '\n';
answer(ans1, ans2);
}
# | 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... |