#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
// int tryCombination(int S[]);
//void answer(int S[], int D[]);
/*const int TAILLEMAXI=5002;
bool trouve[TAILLEMAXI];
int rep[TAILLEMAXI];
int place[TAILLEMAXI];
bool encorepossible[TAILLEMAXI];*/
void exploreCave(int N) {
bool trouve[N];
int rep[N];
int place[N];
bool encorepossible[N];
for (int i=0;i<N;i++){
trouve[i]=false;
rep[i]=0;
place[i]=0;
encorepossible[i]=true;
}
for (int i=0;i<N;i++){
int quest[N];
int nbpos=0;
for (int j=0;j<N;j++){
if (trouve[j]){
quest[j]=rep[j];
encorepossible[j]=false;
}
else {
quest[j]=0;
encorepossible[j]=true;
nbpos++;
}
}
int val=tryCombination(quest);
int nouv;
if (val>i or val==-1){
nouv=0;
}
else {
nouv=1;
}
while (nbpos>1){
int m=(nbpos-1)/2;
int compt=0;
for (int j=0;j<N;j++){
if (encorepossible[j]){
if (compt<=m){
quest[j]=nouv;
compt++;
}
else {
quest[j]=(nouv+1)%2;
}
}
else {
quest[j]=rep[j];
}
}
int val=tryCombination(quest);
if (val>i or val==-1){
int compt=0;
for (int j=0;j<N;j++){
if (encorepossible[j]){
if (compt<=m){
compt++;
}
else {
encorepossible[j]=false;
}
}
}
nbpos=m+1;
}
else {
int compt=0;
for (int j=0;j<N;j++){
if (encorepossible[j]){
if (compt<=m){
compt++;
encorepossible[j]=false;
}
}
}
nbpos-=m+1;
}
}
for (int j=0;j<N;j++){
if (encorepossible[j]){
rep[j]=nouv;
place[j]=i;
}
}
}
answer(rep,place);
}
# | 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... |