#include "cave.h"
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 5 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18;
const ll mod = 1e9 + 7;
bool was[N];
//int dd[N], cor[N], n;
// int tryCombination(int l[]){
// int mn = INT_MAX;
// for(int i = 0; i < n; i++){
// if(l[i] != cor[i]) mn = min(dd[i], mn);
// }
// if(mn == INT_MAX) return -1;
// return mn;
// }
// void answer(int h[], int l[]){
// for(int i = 0; i < n; i++){
// cout << h[i] << " ";
// }
// cout << endl;
// for(int i = 0; i < n; i++){
// cout << l[i] << " ";
// }
// }
void exploreCave(int n) {
int ans[n], d[n], need, cur[n], res;
for(int i = 0; i < n; i++){
ans[i] = 0;
}
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cur[j] = ans[j];
}
res = tryCombination(cur);
if(res == i) need = 1;
else need = 0;
int l = 0, r = n;
while(r - l > 1){
int mid = (r + l) / 2;
for(int j = mid; j < r; j++){
if(was[j]) continue;
cur[j] = 1;
}
res = tryCombination(cur);
for(int j = mid; j < r; j++){
if(was[j]) continue;
cur[j] = 0;
}
if(res != i){
if(need == 1) l = mid;
else r = mid;
} else{
if(need == 1) r = mid;
else l = mid;
}
}
//cout << l << endl;
was[l] = true;
ans[l] = need;
d[l] = i;
}
answer(ans, d);
}
// int main() {
// ios::sync_with_stdio(false);
// cin.tie(NULL);
// cin >> n;
// for(int i = 0; i < n; i++){
// cin >> cor[i];
// }
// for(int i = 0; i < n; i++){
// cin >> dd[i];
// }
// exploreCave(n);
// return 0;
// }
# | 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... |