#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;
const int NB_BITS=13;
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!=NN) {
PutBack(nb);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
5232 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
6396 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
13972 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
5592 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
95 ms |
15948 KB |
Error - Invalid Access |
2 |
Incorrect |
72 ms |
16044 KB |
Error - Invalid Access |
3 |
Incorrect |
76 ms |
16200 KB |
Error - Invalid Access |
4 |
Incorrect |
75 ms |
16360 KB |
Error - Invalid Access |
5 |
Incorrect |
82 ms |
16216 KB |
Error - Invalid Access |
6 |
Incorrect |
78 ms |
16160 KB |
Error - Invalid Access |
7 |
Incorrect |
73 ms |
16164 KB |
Error - Invalid Access |
8 |
Incorrect |
70 ms |
16164 KB |
Error - Invalid Access |
9 |
Incorrect |
66 ms |
16168 KB |
Error - Invalid Access |
10 |
Incorrect |
73 ms |
16248 KB |
Error - Invalid Access |