#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 = 32 - __builtin_clz(n - 1);
for (int i = 0;i < R; i += bit) {
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 |
Correct |
35 ms |
68044 KB |
Output is correct |
2 |
Correct |
28 ms |
68060 KB |
Output is correct |
3 |
Correct |
35 ms |
68176 KB |
Output is correct |
4 |
Correct |
40 ms |
68160 KB |
Output is correct |
5 |
Correct |
45 ms |
68468 KB |
Output is correct |
6 |
Correct |
53 ms |
68456 KB |
Output is correct |
7 |
Correct |
46 ms |
68596 KB |
Output is correct |
8 |
Correct |
49 ms |
68632 KB |
Output is correct |
9 |
Correct |
47 ms |
68720 KB |
Output is correct |
10 |
Correct |
48 ms |
68616 KB |
Output is correct |
11 |
Correct |
51 ms |
68736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
69104 KB |
Output is correct |
2 |
Correct |
147 ms |
74616 KB |
Output is correct |
3 |
Correct |
320 ms |
83052 KB |
Output is correct |
4 |
Correct |
252 ms |
81568 KB |
Output is correct |
5 |
Correct |
263 ms |
81552 KB |
Output is correct |
6 |
Correct |
258 ms |
81740 KB |
Output is correct |
7 |
Correct |
274 ms |
82464 KB |
Output is correct |
8 |
Correct |
243 ms |
80596 KB |
Output is correct |
9 |
Correct |
254 ms |
81224 KB |
Output is correct |
10 |
Correct |
274 ms |
82688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
250 ms |
78788 KB |
Output is correct |
2 |
Incorrect |
56 ms |
70976 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
68120 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
276 ms |
81496 KB |
Output is partially correct - 1700000 bits used |
2 |
Correct |
291 ms |
81488 KB |
Output is partially correct - 1700000 bits used |
3 |
Correct |
278 ms |
82008 KB |
Output is partially correct - 1700000 bits used |
4 |
Correct |
277 ms |
81360 KB |
Output is partially correct - 1700000 bits used |
5 |
Correct |
265 ms |
81492 KB |
Output is partially correct - 1700000 bits used |
6 |
Correct |
289 ms |
81496 KB |
Output is partially correct - 1700000 bits used |
7 |
Correct |
281 ms |
82524 KB |
Output is partially correct - 1697263 bits used |
8 |
Correct |
290 ms |
82512 KB |
Output is partially correct - 1700000 bits used |
9 |
Correct |
285 ms |
82760 KB |
Output is partially correct - 1700000 bits used |
10 |
Correct |
263 ms |
82520 KB |
Output is partially correct - 1700000 bits used |