#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
for(int vez = 0;vez<N;vez++){
int numero = C[vez];
for(int i = 0;(1 << i) <= N;i++){
if(numero & (1 << i)) WriteAdvice('1');
else WriteAdvice('0');
}
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
typedef pair<int,int> ii;
void Assist(unsigned char *A, int N, int K, int R) {
int ptr = 0;
map<int,int> last,atual;
vector<int> sequencia,vaiprecisar;
set<ii> sca;
set<int> defato;
for(int i = 0;i<N;i++){
int numero = 0;
for(int j = 0;(1 << j) <= N;j++){
if(A[ptr] == '1') numero += (1 << j);
ptr++;
}
sequencia.push_back(numero);
}
for(int i = N-1;i>=0;i--){
int v = sequencia[i];
vaiprecisar.push_back(last[v]);
last[v] = i;
}
reverse(vaiprecisar.begin(),vaiprecisar.end());
for(int i = 0;i<K;i++){
ii davez = ii(last[i],i);
sca.insert(davez);
atual[i] = last[i];
defato.insert(i);
}
for(int i = 0;i<N;i++){
int v = sequencia[i];
int checagem = GetRequest();
if(defato.count(v)){
ii antigo = ii(last[v],v);
last[v] = vaiprecisar[i];
ii novo = ii(vaiprecisar[i],v);
sca.erase(antigo);
sca.insert(novo);
}
else{
ii perdeu = *(sca.begin());
sca.erase(perdeu);
defato.erase(perdeu.second);
PutBack(perdeu.second);
last[v] = vaiprecisar[i];
ii novo = ii(vaiprecisar[i],v);
sca.insert(novo);
defato.insert(v);
}
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:40:7: warning: unused variable 'checagem' [-Wunused-variable]
int checagem = GetRequest();
^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
616 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
1052 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
1832 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
1832 KB |
Error - advice must be 0 or 1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
1952 KB |
Error - advice must be 0 or 1 |
2 |
Incorrect |
19 ms |
1960 KB |
Error - advice must be 0 or 1 |
3 |
Incorrect |
23 ms |
1960 KB |
Error - advice must be 0 or 1 |
4 |
Incorrect |
18 ms |
1960 KB |
Error - advice must be 0 or 1 |
5 |
Incorrect |
18 ms |
2064 KB |
Error - advice must be 0 or 1 |
6 |
Incorrect |
20 ms |
2064 KB |
Error - advice must be 0 or 1 |
7 |
Incorrect |
25 ms |
2064 KB |
Error - advice must be 0 or 1 |
8 |
Incorrect |
18 ms |
2144 KB |
Error - advice must be 0 or 1 |
9 |
Incorrect |
19 ms |
2144 KB |
Error - advice must be 0 or 1 |
10 |
Incorrect |
18 ms |
2144 KB |
Error - advice must be 0 or 1 |