#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++) {
if (nb%2==1) {
WriteAdvice('1');
}
else {
WriteAdvice('0');
}
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;
void Assist(unsigned char *AA, int NN, int KK, int RR) {
int nb;
for (int i=0;i<NN;i++) {
nb=GetRequest();
nb=0;
int multi=0;
for (int j=NB_BITS*i;j<NB_BITS*(i+1);j++) {
if (AA[j]=='1') {
nb+=multi;
}
multi*=2;
}
if (nb!=NN) {
PutBack(nb);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
5228 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
6308 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
76 ms |
13976 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
5676 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
70 ms |
15964 KB |
Error - Invalid Access |
2 |
Incorrect |
91 ms |
16300 KB |
Error - Invalid Access |
3 |
Incorrect |
95 ms |
16404 KB |
Error - Invalid Access |
4 |
Incorrect |
73 ms |
16344 KB |
Error - Invalid Access |
5 |
Incorrect |
101 ms |
16176 KB |
Error - Invalid Access |
6 |
Incorrect |
93 ms |
16320 KB |
Error - Invalid Access |
7 |
Incorrect |
77 ms |
16244 KB |
Error - Invalid Access |
8 |
Incorrect |
82 ms |
16184 KB |
Error - Invalid Access |
9 |
Incorrect |
75 ms |
16252 KB |
Error - Invalid Access |
10 |
Incorrect |
76 ms |
16408 KB |
Error - Invalid Access |