#include <bits/stdc++.h>
using namespace std;
#include "advisor.h"
void ComputeAdvice(int *C, int N, int K, int M){
int next[N], last[N];
fill(last, last+N, N);
bool on[N], r[N+K] = {};
for(int i=N; --i>=0; ){
next[i] = last[C[i]];
last[C[i]] = i;
on[i] = i < K;
}
priority_queue<array<int, 2>> q;
for(int i=0; i<N; ++i){
if(i < K) q.push({last[i], i});
last[i] = i < K ? i : -1;
}
for(int i=0; i<N; ++i){
if(!on[C[i]]){
while(!on[q.top()[1]]) q.pop();
auto [t, j] = q.top(); q.pop();
r[last[j]] = !(on[j] = 0);
}
q.push({next[C[i]] + K, C[i]});
on[C[i]] = 1;
last[C[i]] = K + i;
}
for(int i=0; i<N+K; ++i) WriteAdvice(r[i]);
}
#include <bits/stdc++.h>
using namespace std;
#include "assistant.h"
void Assist(unsigned char *A, int N, int K, int R){
vector<int> s;
bool on[N] = {};
for(int i=0; i<K; ++i){
on[i] = 1;
if(!!A[i]) s.push_back(i);
}
for(int i=0; i<N; ++i){
int j = GetRequest();
if(!on[j]){
PutBack(s.back());
on[s.back()] = 0;
s.pop_back();
on[j] = 1;
}
if(!!A[K+i]) s.push_back(j);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
480 KB |
Output is correct |
2 |
Incorrect |
0 ms |
484 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
1076 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
3704 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
644 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
79 ms |
4484 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
75 ms |
4540 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
75 ms |
4476 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
73 ms |
4552 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
84 ms |
4560 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
80 ms |
4552 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
75 ms |
4528 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
72 ms |
4528 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
77 ms |
4572 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
74 ms |
4500 KB |
Output isn't correct - not an optimal way |