#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
const int nn = 2e5 + 5;
vector<int> x[nn];
int cur[nn], save[nn], last[nn];
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i = N - 1; i >= 0; i--) {
x[C[i]].push_back(i + K);
}
set<pair<int,int> > s;
for(int i = 0; i < K; i++) {
cur[i] = 1;
s.insert({x[i].size() ? x[i].back() : N + K, i});
if(x[i].size()) x[i].pop_back();
last[i] = i;
}
for(int i = K; i < N + K; i++) {
int c = C[i - K];
if(cur[c]) {
save[last[c]] = 1;
s.erase({i, c});
}
else {
pair<int,int> p = *--s.end();
s.erase(p);
cur[p.second] = 0;
}
cur[c] = 1;
s.insert({(x[c].size() ? x[c].back() : N + K), c});
if(x[c].size()) x[c].pop_back();
last[c] = i;
}
for(int i = 0; i < N + K; i++) WriteAdvice(save[i]);
}
#include<bits/stdc++.h>
using namespace std;
#include "assistant.h"
const int nn = 2e5 + 5;
int last[nn], cur[nn];
void Assist(unsigned char *A, int N, int K, int R) {
queue<int> q;
for(int i = 0; i < K; i++) {
int b = A[i];
if(!b)
q.push(i);
cur[i] = 1;
}
for(int i = K; i < N + K; i++) {
int c = GetRequest();
if(cur[c]) {
int b = A[i];
if(!b)
q.push(c);
continue;
}
cur[c] = 1;
int x = q.front();
q.pop();
PutBack(x);
cur[x] = 0;
int b = A[i];
if(!b)
q.push(c);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
5256 KB |
Output is correct |
2 |
Incorrect |
4 ms |
5264 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
6108 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
12136 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
5676 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
107 ms |
13508 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
103 ms |
13652 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
120 ms |
13924 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
107 ms |
13956 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
102 ms |
14188 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
107 ms |
13852 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
93 ms |
13936 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
95 ms |
13900 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
118 ms |
14028 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
102 ms |
13768 KB |
Output isn't correct - not an optimal way |