#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int bits = log2(K);
for(int i = 0; i < N; i++)
for(int j = 0; j < bits; j++)
WriteAdvice((bool)C[i]&1<<j);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
priority_queue<pair<int, int>> q;
int last[N], nxt[N];
memset(last, 1, sizeof last);
int C[N], bits = log2(K);
for(int i = 0; i < N; i++)
for(int j = 0; j < bits; j++)
C[i]|=A[i*bits+j]-'0' << j;
for(int i = N; i--;)
nxt[i] = last[C[i]], last[C[i]] = i;
bool on[N];
memset(on, 0, sizeof on);
for(int i = 0; i < K; i++)
q.push({last[i], i}), on[i] = 1;
for(int i = 0; i < N; i++) {
int col = GetRequest();
if(!on[col]) {
PutBack(q.top().second);
on[q.top().second] = 0;
q.pop();
q.push({nxt[i], i});
on[col] = 1;
}
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:13:24: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
13 | C[i]|=A[i*bits+j]-'0' << j;
| ~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
520 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1600 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
202 ms |
11184 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
696 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
262 ms |
13668 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
277 ms |
13796 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
252 ms |
13748 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
287 ms |
13744 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
254 ms |
13644 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
276 ms |
13816 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
255 ms |
13776 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
258 ms |
13744 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
265 ms |
13756 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
258 ms |
13700 KB |
Error - Putting back a color that is not on the scaffold |