#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
const int LG = __lg(N);
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 <bits/stdc++.h>
using namespace std;
const int maxn = 100025;
int C[maxn];
vector<int> last[maxn];
int scaffold[maxn];
bool onScaffold[maxn];
void Assist(unsigned char *A, int N, int K, int R) {
const int LG = __lg(N);
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';
auto getLast = [](int i) {
return last[i].empty()
? maxn
: last[i].back();
};
for (int i = N-1; i >= 0; i--)
last[C[i]].push_back(i);
set<pair<int,int>, greater<>> st; // last, j
for (int i = 0; i < K; i++) {
scaffold[i] = i, onScaffold[i] = true;
st.insert({ getLast(i), i });
}
for (int i = 0; i < N; i++) {
int req = GetRequest();
if (!onScaffold[req]) {
int pos = st.begin() -> second;
st.erase(st.begin());
if (last[scaffold[pos]].size())
last[scaffold[pos]].pop_back();
st.insert({ getLast(req), pos });
onScaffold[req] = true;
onScaffold[scaffold[pos]] = false;
PutBack(scaffold[pos]);
scaffold[pos] = req;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
3284 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
36 ms |
4392 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
358 ms |
15396 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
3172 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
453 ms |
17920 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
419 ms |
18096 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
429 ms |
18184 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
429 ms |
18480 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
442 ms |
18292 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
436 ms |
18404 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
410 ms |
18072 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
426 ms |
18224 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
432 ms |
18352 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
421 ms |
18504 KB |
Output isn't correct - not an optimal way |