#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) + 1;
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) + 1;
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 });
PutBack(scaffold[pos]);
scaffold[pos] = req;
onScaffold[scaffold[pos]] = false;
onScaffold[req] = true;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3292 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3044 KB |
Error - Not putting back color when it is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
37 ms |
4416 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
351 ms |
16096 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
3172 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
420 ms |
18964 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Incorrect |
472 ms |
19028 KB |
Error - Not putting back color when it is not on the scaffold |
3 |
Incorrect |
472 ms |
18956 KB |
Error - Not putting back color when it is not on the scaffold |
4 |
Incorrect |
418 ms |
19084 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Incorrect |
427 ms |
19404 KB |
Error - Not putting back color when it is not on the scaffold |
6 |
Incorrect |
417 ms |
19084 KB |
Error - Not putting back color when it is not on the scaffold |
7 |
Incorrect |
435 ms |
19228 KB |
Error - Not putting back color when it is not on the scaffold |
8 |
Incorrect |
414 ms |
19280 KB |
Error - Not putting back color when it is not on the scaffold |
9 |
Incorrect |
425 ms |
19444 KB |
Error - Not putting back color when it is not on the scaffold |
10 |
Incorrect |
430 ms |
20108 KB |
Error - Not putting back color when it is not on the scaffold |