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<bits/stdc++.h>
#include "cave.h"
using namespace std;
const int MAX_VAL=5000+5;
int nbVal,ans,nbFait,deb,fin,mid;
vector<int> quest;
vector<int> repPos,rep;
int numPorte[MAX_VAL],repEtat[MAX_VAL];
void modif() {
for (int i=0;i<nbFait;i++) {
quest[numPorte[i]]=repEtat[i];
}
}
int askQuest(vector<int> v) {
int arr[nbVal];
copy(v.begin(),v.end(),arr);
return tryCombination(arr);
}
void exploreCave(int N) {
nbVal=N;
for (int i=0;i<nbVal;i++) {
quest.clear();
for (int j=0;j<nbVal;j++) {
quest.push_back(0);
}
modif();
ans=askQuest(quest);
if (ans>=i) {
repEtat[i]=0;
}
else {
repEtat[i]=1;
}
deb=0;
fin=nbVal-1;
while (deb!=fin) {
mid=(deb+fin)/2;
for (int j=0;j<nbVal;j++) {
if (j>=deb and j<=mid) {
quest.push_back(repEtat[i]);
}
else {
quest.push_back(1-repEtat[i]);
}
}
modif();
ans=askQuest(quest);
if (ans>=i) {
fin=mid;
}
else {
deb=mid+1;
}
}
repEtat[i]=deb;
nbFait++;
}
for (int i=0;i<nbVal;i++) {
rep.push_back(repEtat[i]);
for (int j=0;j<nbVal;j++) {
if (repEtat[j]==i) {
rep.push_back(j);
}
}
}
int arrPos[nbVal],arrRep[nbVal];
copy(repPos.begin(),repPos.end(),arrPos);
copy(rep.begin(),rep.end(),arrRep);
answer(arrPos,arrRep);
}
# | 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... |