#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
int n2 = 0;
for (n2 = 0; (1 << (n2 + 1)) < N; ++ n2) {
}
for (int i = 0; i < N; ++ i) {
int x = C[i];
for (int j = 0; j <= n2; ++ j) {
WriteAdvice(x % 2);
x /= 2;
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5;
bool viz[nmax + 1];
int f[nmax + 1];
int nxt[nmax + 1];
void Assist(unsigned char *A, int N, int K, int R) {
vector<int> c;
int n2 = 0;
for (n2 = 0; (1 << (n2 + 1)) < N; ++ n2) {
}
for (int i = 0; i < R; i += n2 + 1) {
int x = 0;
int p2 = 1;
for (int j = i; j <= i + n2; ++ j) {
x = x + p2 * A[j];
p2 *= 2;
}
c.push_back(x);
}
for (int i = 0; i < N; ++ i)
f[i] = (1 << 30);
for (int i = N - 1; i > 0; -- i) {
nxt[i] = -f[c[i]];
f[c[i]] = i;
}
set<pair<int, int>> s;
for (int i = 0; i < K; ++ i) {
viz[i] = 1;
s.insert({-f[i], i});
}
int i;
for (i = 0; i < N; i++) {
int req = GetRequest();
if (viz[req] == 1) {
s.erase({-i, req});
} else {
int x = s.begin() -> second;
PutBack(x);
viz[x] = 0;
s.erase(s.begin());
}
viz[req] = 1;
s.insert({nxt[i], req});
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
640 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
2000 KB |
Output is correct |
2 |
Correct |
209 ms |
7896 KB |
Output is correct |
3 |
Correct |
423 ms |
16880 KB |
Output is correct |
4 |
Correct |
346 ms |
15348 KB |
Output is correct |
5 |
Correct |
443 ms |
15384 KB |
Output is correct |
6 |
Correct |
378 ms |
15644 KB |
Output is correct |
7 |
Incorrect |
378 ms |
16248 KB |
Output isn't correct - not an optimal way |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
304 ms |
12352 KB |
Output is correct |
2 |
Incorrect |
28 ms |
5624 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
776 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
444 ms |
15048 KB |
Output isn't correct - not an optimal way |
2 |
Partially correct |
377 ms |
15236 KB |
Output is partially correct - 1700000 bits used |
3 |
Partially correct |
377 ms |
15260 KB |
Output is partially correct - 1700000 bits used |
4 |
Partially correct |
366 ms |
15168 KB |
Output is partially correct - 1700000 bits used |
5 |
Partially correct |
498 ms |
15220 KB |
Output is partially correct - 1700000 bits used |
6 |
Partially correct |
430 ms |
15368 KB |
Output is partially correct - 1700000 bits used |
7 |
Partially correct |
465 ms |
15500 KB |
Output is partially correct - 1697263 bits used |
8 |
Partially correct |
432 ms |
15324 KB |
Output is partially correct - 1700000 bits used |
9 |
Partially correct |
401 ms |
15696 KB |
Output is partially correct - 1700000 bits used |
10 |
Partially correct |
442 ms |
15252 KB |
Output is partially correct - 1700000 bits used |