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;
//int tryCombination(int S[]);\
void answer(int S[], int D[]);
void exploreCave(int N) {
int S[N];
int D[N];
vector<int> unknown(N);
iota(unknown.begin(), unknown.end(), 0);
int sor[N];
for (int i = 0; i < N; ++i)
{
sor[i]=0;
}
int last = tryCombination(sor);
for (int i = 0; i < N; i++){
int l = 0, r = unknown.size()-1;
while (l<r){
int mid = l+(r-l)/2;
for (int j = 0; j <= mid; j++){
sor[unknown[j]]=1;
}
int x = tryCombination(sor);
if ((x==i)!=(last==i)){
r=mid;
}
else {
l=mid+1;
}
for (int j = 0; j <= mid; j++){
sor[unknown[j]]=0;
}
}
S[unknown[l]]=i;
if (last==i) {
D[unknown[l]]=1;
sor[unknown[l]]=1;
last = tryCombination(sor);
}
else D[unknown[l]]=0;
swap(unknown[l],unknown.back());
unknown.pop_back();
}
answer(D,S);
}
Compilation message (stderr)
cave.cpp:4:1: warning: multi-line comment [-Wcomment]
4 | //int tryCombination(int S[]);\
| ^
# | 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... |