//#include "assistant.h"
#include "advisor.h"
#include <vector>
#include <set>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0;i<N;i++){
for(int j=0;j<20;j++){
if(C[i]&1)WriteAdvice(1);
else WriteAdvice(0);
C[i]/=2;
}
}
}
/*void Assist(unsigned char *A, int N, int K, int R) {
vector<int> V(N),cnt(N);
set<int> S;
set<pair<int,int>> M;
for(int i=0;i<K;i++)S.insert(i);
for(int i=0;i<N;i+=20){
for(int j=0;j<20;j++){
V[i]*=2;
V[i]+=A[i];
}
}
vector<vector<int>> needed(N);
for(int i=0;i<N;i++)needed[i].push_back(N);
for(int i=N-1;i>=0;i++)needed[V[i]].push_back(i);
for(int i=0;i<K;i++){
M.insert({-needed[0][0],i});
}
for (int i = 0; i < N; i++) {
int req = GetRequest();
if (S.find(req)==S.end()){
auto it=M.begin();
S.erase(it->second);
S.insert(req);
PutBack(it->second);
M.erase(it);
cnt[req]++;
M.insert({-needed[req][cnt[req]],req});
}
else{
M.erase({-needed[req][cnt[req]],req});
cnt[req]++;
M.insert({-needed[req][cnt[req]],req});
}
}
}*/
#include "assistant.h"
//#include "advisor.h"
#include <vector>
#include <set>
using namespace std;
/*void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0;i<N;i++){
for(int j=0;j<20;j++){
if(C[i]&1)WriteAdvice(1);
else WriteAdvice(0);
C[i]/=2;
}
}
}*/
void Assist(unsigned char *A, int N, int K, int R) {
vector<int> V(N),cnt(N);
set<int> S;
set<pair<int,int>> M;
for(int i=0;i<K;i++)S.insert(i);
for(int i=0;i<N;i+=20){
for(int j=0;j<20;j++){
V[i]*=2;
V[i]+=A[i];
}
}
vector<vector<int>> needed(N);
for(int i=0;i<N;i++)needed[i].push_back(N);
for(int i=N-1;i>=0;i++)needed[V[i]].push_back(i);
for(int i=0;i<K;i++){
M.insert({-needed[0][0],i});
}
for (int i = 0; i < N; i++) {
int req = GetRequest();
if (S.find(req)==S.end()){
auto it=M.begin();
S.erase(it->second);
S.insert(req);
PutBack(it->second);
M.erase(it);
cnt[req]++;
M.insert({-needed[req][cnt[req]],req});
}
else{
M.erase({-needed[req][cnt[req]],req});
cnt[req]++;
M.insert({-needed[req][cnt[req]],req});
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
664 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
40 ms |
3812 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
3296 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
536 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
3812 KB |
Error - advice is too long |
2 |
Incorrect |
26 ms |
3732 KB |
Error - advice is too long |
3 |
Incorrect |
24 ms |
3888 KB |
Error - advice is too long |
4 |
Incorrect |
24 ms |
3820 KB |
Error - advice is too long |
5 |
Incorrect |
22 ms |
3896 KB |
Error - advice is too long |
6 |
Incorrect |
27 ms |
3796 KB |
Error - advice is too long |
7 |
Incorrect |
23 ms |
3884 KB |
Error - advice is too long |
8 |
Incorrect |
25 ms |
3956 KB |
Error - advice is too long |
9 |
Incorrect |
23 ms |
3864 KB |
Error - advice is too long |
10 |
Incorrect |
29 ms |
3760 KB |
Error - advice is too long |