#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
const int LG = 13;
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 = 13;
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;
int pos = -1;
for (int j = 0; j < K; j++)
if(pos == -1 || getLast(scaffold[pos]) < getLast(scaffold[j]))
pos = j;
// st.erase(st.begin());
last[req].pop_back();
PutBack(scaffold[pos]);
onScaffold[scaffold[pos]] = false;
onScaffold[req] = true;
scaffold[pos] = req;
// st.insert({ getLast(scaffold[pos]), pos });
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3284 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3172 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
38 ms |
7464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
269 ms |
19224 KB |
Execution killed with signal 11 |
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 |
Runtime error |
334 ms |
21748 KB |
Execution killed with signal 11 |
2 |
Runtime error |
323 ms |
21740 KB |
Execution killed with signal 11 |
3 |
Runtime error |
328 ms |
22252 KB |
Execution killed with signal 11 |
4 |
Runtime error |
325 ms |
22124 KB |
Execution killed with signal 11 |
5 |
Runtime error |
332 ms |
22396 KB |
Execution killed with signal 11 |
6 |
Runtime error |
325 ms |
22264 KB |
Execution killed with signal 11 |
7 |
Runtime error |
328 ms |
22380 KB |
Execution killed with signal 11 |
8 |
Runtime error |
329 ms |
22272 KB |
Execution killed with signal 11 |
9 |
Runtime error |
325 ms |
22336 KB |
Execution killed with signal 11 |
10 |
Runtime error |
328 ms |
22140 KB |
Execution killed with signal 11 |