#include "advisor.h"
#include <vector>
#include <set>
#include <cmath>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int logn=13;
for(int i=0;i<N;i++){
int x=C[i];
for(int j=0;j<logn;j++){
if(x&1)WriteAdvice(1);
else WriteAdvice(0);
x/=2;
}
}
}
#include "assistant.h"
#include <vector>
#include <set>
#include <cmath>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
int logn=13;
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++){
for(int j=logn-1;j>=0;j--){
V[i]*=2;
V[i]+=(int)(A[i*logn+j]);
}
}
vector<vector<int>> needed(N,vector<int>());
for(int i=0;i<N;i++){
needed[V[i]].push_back(i);
}
for(int i=0;i<N;i++)needed[i].push_back(N);
for(int i=0;i<K;i++){
M.insert({-needed[i][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 |
Correct |
0 ms |
516 KB |
Output is correct |
2 |
Correct |
1 ms |
520 KB |
Output is correct |
3 |
Correct |
4 ms |
792 KB |
Output is correct |
4 |
Correct |
9 ms |
992 KB |
Output is correct |
5 |
Correct |
14 ms |
1308 KB |
Output is correct |
6 |
Correct |
14 ms |
1276 KB |
Output is correct |
7 |
Correct |
14 ms |
1408 KB |
Output is correct |
8 |
Correct |
14 ms |
1440 KB |
Output is correct |
9 |
Correct |
16 ms |
1428 KB |
Output is correct |
10 |
Correct |
17 ms |
1568 KB |
Output is correct |
11 |
Correct |
18 ms |
1412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
2304 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
273 ms |
15596 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
508 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
327 ms |
18900 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
331 ms |
19008 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
329 ms |
19428 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
344 ms |
19524 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
319 ms |
19552 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
320 ms |
19408 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
322 ms |
19420 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
369 ms |
19416 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
313 ms |
19608 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
335 ms |
19316 KB |
Output isn't correct - not an optimal way |