#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int T = log2(N) + 1;
for(int i = 0; i < N; i++) {
for(int j = 0; j < T; j++) WriteAdvice(C[i] >> j & 1);
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int query[N];
bool chosen[N];
vector<int> nxt[N];
void Assist(unsigned char *A, int N, int K, int R) {
int T = log2(N) + 1;
int cnt = 0;
for(int i = 0; i < N; i++) {
for(int j = 0; j < T; j++) {
if (int(A[cnt])) query[i] |= (1 << j);
cnt++;
}
}
for(int i = N - 1; i >= 0; i--) nxt[query[i]].push_back(i);
priority_queue<pair<int, int> > Q;
for(int i = 0; i < K; i++) {
int tmp = nxt[i].empty() ? N : nxt[i].back();
Q.push({tmp, i});
chosen[i] = 1;
}
for(int i = 0; i < N; i++) {
GetRequest();
int x = query[i];
if (chosen[x] == 0) {
int useless, j; tie(useless, j) = Q.top(); Q.pop();
chosen[j] = 0;
PutBack(j);
chosen[x] = 1;
nxt[x].pop_back();
int tmp = nxt[x].empty() ? N : nxt[x].back();
Q.push({N, x});
}
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:42:11: warning: unused variable 'tmp' [-Wunused-variable]
42 | int tmp = nxt[x].empty() ? N : nxt[x].back();
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3092 KB |
Output is correct |
2 |
Incorrect |
1 ms |
3084 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
4460 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
221 ms |
15248 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3092 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
276 ms |
18132 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
273 ms |
17952 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
288 ms |
18112 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
272 ms |
18112 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
287 ms |
18172 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
283 ms |
18468 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
272 ms |
18124 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
304 ms |
17988 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
280 ms |
17976 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
290 ms |
19172 KB |
Output isn't correct - not an optimal way |