#include "advisor.h"
#include <iostream>
using std::cerr;
const int LG = 13;
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i = 0; i < N; i++) {
for (int j = 0; j < LG; j++) {
WriteAdvice(C[i] >> j & 1);
}
}
// cerr << "C = ";
// for (int i = 0; i < N; i++)
// cerr << C[i] << ' ';
// cerr << '\n';
}
#include "assistant.h"
#include <iostream>
#include <vector>
#include <cassert>
using std::cerr;
using std::vector;
const int maxn = 100025;
const int LG = 13;
int C[maxn];
vector<int> last[maxn];
int scaffold[maxn];
bool onScaffold[maxn];
void Assist(unsigned char *A, int N, int K, int R) {
for (int i = 0; i < N; i++) {
for (int j = 0; j < LG; j++) {
C[i] |= A[i*LG + j] * (1<<j);
}
}
// cerr << "C = ";
// for (int i = 0; i < N; i++)
// cerr << C[i] << ' ';
// cerr << '\n';
for (int i = 0; i < K; i++)
scaffold[i] = i, onScaffold[i] = true;
for (int i = 0; i < N; i++)
last[i].push_back(maxn);
for (int i = N-1; i >= 0; i--)
last[C[i]].push_back(i);
for (int i = 0; i < N; i++) {
int req = GetRequest();
last[C[i]].pop_back();
if (!onScaffold[req]) {
// for (int i = 0; i < N; i++) last[i] = maxn;
// for (int j = N-1; j > i; j--)
// last[C[j]] = j;
assert(C[i] == req);
// assert(last[C[i]].back() == i);
int pos = -1;
for (int j = 0; j < K; j++)
if(pos == -1 ||
last[scaffold[pos]].back() < last[scaffold[j]].back())
pos = j;
onScaffold[req] = true;
onScaffold[scaffold[pos]] = false;
PutBack(scaffold[pos]);
scaffold[pos] = req;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3284 KB |
Output is correct |
2 |
Correct |
3 ms |
3172 KB |
Output is correct |
3 |
Correct |
5 ms |
3204 KB |
Output is correct |
4 |
Correct |
12 ms |
3648 KB |
Output is correct |
5 |
Correct |
18 ms |
3708 KB |
Output is correct |
6 |
Correct |
20 ms |
3708 KB |
Output is correct |
7 |
Correct |
19 ms |
3852 KB |
Output is correct |
8 |
Correct |
43 ms |
3708 KB |
Output is correct |
9 |
Correct |
37 ms |
3716 KB |
Output is correct |
10 |
Correct |
41 ms |
3708 KB |
Output is correct |
11 |
Correct |
36 ms |
3716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
40 ms |
7464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
274 ms |
21940 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
3044 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
332 ms |
25836 KB |
Execution killed with signal 6 |
2 |
Runtime error |
353 ms |
25960 KB |
Execution killed with signal 6 |
3 |
Runtime error |
351 ms |
25964 KB |
Execution killed with signal 6 |
4 |
Runtime error |
343 ms |
25836 KB |
Execution killed with signal 6 |
5 |
Runtime error |
341 ms |
26092 KB |
Execution killed with signal 6 |
6 |
Runtime error |
340 ms |
26000 KB |
Execution killed with signal 6 |
7 |
Runtime error |
366 ms |
26072 KB |
Execution killed with signal 6 |
8 |
Runtime error |
334 ms |
25944 KB |
Execution killed with signal 6 |
9 |
Runtime error |
368 ms |
25908 KB |
Execution killed with signal 6 |
10 |
Runtime error |
354 ms |
26076 KB |
Execution killed with signal 6 |