This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//Sylwia Sapkowska
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int n) {
vector<bool>fixed(n);
int s[n], where[n];
for (int i = 0; i<n; i++) s[i] = 0;
for (int i = 1; i<=n; i++){
int l = 1, r = n;
int ans = 1;
int curr = tryCombination(s);
while (r >= l){
int mid = (l+r)/2;
auto t = s;
for (int j = 0; j<mid; j++){
if (!fixed[j]){
t[j] = 1;
}
}
int get = tryCombination(t);
if (get == -1) get = n;
if ((curr < i && get >= i) || (curr >= i && get < i)){
curr = mid;
r = mid-1;
} else {
l = mid+1;
}
}
fixed[ans] = 1;
where[i] = ans;
s[ans] = (curr >= i ? 0 : 1);
}
answer(s, where);
}
# | 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... |