This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
//#define int ll
const ll mod=1e9+7;
void exploreCave(int n){
//vector<int> c(n,1),d(n),t(n);
int c[n],d[n],t[n];
for(int i=0;i<n;i++) c[i] = 1;
int p = tryCombination(c);
if (p == -1) p = n;
for (int i = 0 ; i < n ; i++){
if(p > i){
int l = 0, r = n - 1;
while(l < r){
int m = (l + r) / 2;
int cur[n];
for(int j = 0; j < n; j++) cur[j] = c[j];
for(int j = l ; j <= m ; j++){
if(t[j] == 0) cur[i] = 0;
}
int k = tryCombination(cur);
if(k == -1) k = n;
if(k == i) r = m;
else l = m + 1;
}
t[l] = 1;
c[l] = 1;
d[i] = l;
}
if(p <= i){
int l = 0, r = n - 1;
while(l < r){
int m = (l + r) / 2;
int cur[n];
for(int j = 0; j < n; j++) cur[j] = c[j];
for(int j = l ; j <= m ; j++){
if(t[j] == 0) cur[i] = 0;
}
int k = tryCombination(cur);
if(k == -1) k = n;
if(k >= i) r = m;
else l = m + 1;
}
t[l] = 1;
c[l] = 0;
d[i] = l;
}
}
answer(c,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... |