#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;
const int NB_BITS=13,MAX_COUL=100*1000,INFINI=1000*1000*1000;
set<int> date[MAX_COUL];
int pres[MAX_COUL];
set<pair<int,int>> proch;
set<int>::iterator it;
set<pair<int,int>>::iterator it2;
void crypte(int nb) {
cout<<nb<<endl;
for (int i=0;i<NB_BITS;i++) {
WriteAdvice(char(int('0')+nb%2));
//cout<<char(int('0')+nb%2)<<" ";
nb/=2;
}
}
void ComputeAdvice(int *ajout, int nbCoul, int taille, int tailleMax) {
for (int i=0;i<nbCoul;i++) {
date[i].insert(INFINI);
}
for (int i=0;i<nbCoul;i++) {
date[ajout[i]].insert(i);
}
for (int i=0;i<taille;i++) {
it=date[i].begin();
proch.insert(make_pair(*it,i));
pres[i]=1;
}
for (int i=0;i<nbCoul;i++) {
if (pres[ajout[i]]==1) {
crypte(nbCoul);
proch.erase(make_pair(i,ajout[i]));
it=date[ajout[i]].lower_bound(i+1);
proch.insert(make_pair(*it,ajout[i]));
}
else {
it2=proch.lower_bound(make_pair(INFINI,INFINI));
it2--;
crypte((*it2).second);
pres[(*it2).second]=0;
proch.erase(*it2);
it=date[ajout[i]].lower_bound(i+1);
pres[ajout[i]]=1;
proch.insert(make_pair(*it,ajout[i]));
}
}
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
unsigned char *ligne;
int decrypte(int pos) {
int rep=0,multi=1;
for (int i=NB_BITS*pos;i<NB_BITS*(pos+1);i++) {
rep+=multi*(int(ligne[i])-int('0'));
multi*=2;
}
return rep;
}
void Assist(unsigned char *AA, int NN, int KK, int RR) {
ligne=AA;
int nb;
for (int i=0;i<NN;i++) {
nb=decrypte(i);
cout<<nb<<endl;
nb=GetRequest();
nb=decrypte(i);
if (nb!=N) {
PutBack(nb);
}
}
}
Compilation message
assistant.cpp: In function 'int decrypte(int)':
assistant.cpp:9:14: error: 'NB_BITS' was not declared in this scope; did you mean 'NFDBITS'?
9 | for (int i=NB_BITS*pos;i<NB_BITS*(pos+1);i++) {
| ^~~~~~~
| NFDBITS
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:24:13: error: 'N' was not declared in this scope
24 | if (nb!=N) {
| ^