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;
using LL = long long;
const int MOD = (int)1e9 + 7;
const int NS = (int)5004;
int N;
int S[NS], D[NS], chk[NS];
vector<int> need;
void exploreCave(int Nin) {
N = Nin;
for(int i = 0; i < N; ++i){
int pos = tryCombination(S);
int nows;
if(pos > i){
nows = 0;
}
else{
nows = 1;
}
need.clear();
for(int j = 0; j < N; ++j){
if(!chk[j]){
need.push_back(j);
}
}
int low = 0, high = (int)need.size() - 1, mid;
while(low < high){
mid = (low + high) >> 1;
if(nows){
for(int j = low; j <= mid; ++j){
S[need[j]] = 1;
}
}
else{
for(int j = mid + 1; j <= high; ++j){
S[need[j]] = 1;
}
}
int rv = tryCombination(S);
if(rv == -1){
rv = MOD;
}
if(nows){
for(int j = low; j <= mid; ++j){
S[need[j]] = 0;
}
}
else{
for(int j = mid + 1; j <= high; ++j){
S[need[j]] = 0;
}
}
if(rv > i){
high = mid;
}
else{
low = mid + 1;
}
}
S[need[low]] = nows;
D[need[low]] = i;
chk[need[low]] = 1;
}
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... |