#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ComputeAdvice(int* C, int _N, int K, int M) {
int n = _N;
int bit = 31 - __builtin_clz(n - 1);
for (int j = 0;j < n;j++) {
for (int i = bit;i >= 0;i--) {
WriteAdvice((C[j] >> i) & 1);
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool in[100100];
queue<int> q[100100];
void Assist(unsigned char* A, int _N, int K, int R) {
int n = _N;
int bit = 31 - __builtin_clz(n - 1);
for (int i = 0;i < R; i += bit + 1) {
int now = 0;
for (int j = i;j <= i + bit;j++) now = (now << 1) | A[j];
q[now].push(i / bit);
}
for (int i = 0;i < n;i++) q[i].push(n);
set<pair<int, int>, greater<pair<int, int>>> s;
for (int i = 0;i < K;i++) s.insert({ q[i].front(), i }), in[i] = 1;
for (int i = 0;i < n;i++) {
// for (auto& x : s) {
// cout << x.second << ' ';
// }
// cout << '\n';
int req = GetRequest();
int prev = q[req].front();
q[req].pop();
if (in[req]) {
s.erase({ prev, req });
s.insert({ q[req].front(), req });
continue;
}
auto x = s.begin();
PutBack(x->second);
in[x->second] = 0;
s.erase(x);
in[req] = 1;
s.insert({ q[req].front(), req });
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
68056 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
69368 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
215 ms |
79888 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
68144 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
279 ms |
82496 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
269 ms |
82576 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
256 ms |
82516 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
264 ms |
82580 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
265 ms |
82424 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
265 ms |
82456 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
268 ms |
82572 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
268 ms |
82736 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
289 ms |
82540 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
315 ms |
82580 KB |
Output isn't correct - not an optimal way |