#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>
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();
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;
last[C[i]].pop_back();
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 |
3332 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3044 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
117 ms |
4532 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2587 ms |
14592 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
3264 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2529 ms |
17376 KB |
Time limit exceeded |
2 |
Execution timed out |
2508 ms |
17576 KB |
Time limit exceeded |
3 |
Execution timed out |
2600 ms |
17260 KB |
Time limit exceeded |
4 |
Execution timed out |
2591 ms |
17372 KB |
Time limit exceeded |
5 |
Execution timed out |
2512 ms |
17388 KB |
Time limit exceeded |
6 |
Execution timed out |
2517 ms |
17132 KB |
Time limit exceeded |
7 |
Execution timed out |
2510 ms |
17272 KB |
Time limit exceeded |
8 |
Execution timed out |
2598 ms |
17364 KB |
Time limit exceeded |
9 |
Execution timed out |
2515 ms |
17272 KB |
Time limit exceeded |
10 |
Execution timed out |
2594 ms |
17268 KB |
Time limit exceeded |