#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+20;
vector<int> t[MAXN];
int A[2*MAXN];
void ComputeAdvice(int *C, int N, int K, int M){ //C = color requests; N = length of C; K = number of colors on the scaffold
for(int i = N-1;i >= 0;--i){
t[C[i]].push_back(i); //the "times" color C[i] is needed, sorted in decreasing order
}
set<pair<int,int>> s;
for(int i = 0;i<K;++i){
if(t[i].empty()) s.insert({N,i});
else s.insert({t[i].back(),i});
}
for(int i = 0;i<N;++i){
if(s.begin()->first == i) s.erase(s.begin());
else{
A[prev(s.end())->second] = 1;
s.erase(prev(s.end()));
}
t[C[i]].pop_back();
s.emplace(t[C[i]].empty() ? N : t[C[i]].back(),i+K);
}
for(int i = 0;i<K+N;++i) WriteAdvice(A[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
vector<int> nxt; set<int> s;
for (int i = 0; i < K; i++) {
if(A[i] == 1) nxt.push_back(i);
s.insert(i);
}
for(int i = 0; i < N; i++){
int x = GetRequest();
if(s.find(x) == s.end()){
int y = nxt.back();
PutBack(y);
nxt.pop_back();
s.erase(y);
s.insert(x);
}
if(A[i+K] == 1) nxt.push_back(x);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2952 KB |
Output is correct |
2 |
Correct |
2 ms |
2968 KB |
Output is correct |
3 |
Correct |
3 ms |
3084 KB |
Output is correct |
4 |
Correct |
3 ms |
2988 KB |
Output is correct |
5 |
Correct |
4 ms |
3132 KB |
Output is correct |
6 |
Correct |
5 ms |
3132 KB |
Output is correct |
7 |
Correct |
4 ms |
3272 KB |
Output is correct |
8 |
Correct |
5 ms |
3388 KB |
Output is correct |
9 |
Correct |
5 ms |
3268 KB |
Output is correct |
10 |
Correct |
6 ms |
3448 KB |
Output is correct |
11 |
Correct |
6 ms |
3396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
3660 KB |
Output is correct |
2 |
Correct |
39 ms |
5848 KB |
Output is correct |
3 |
Correct |
95 ms |
13188 KB |
Output is correct |
4 |
Correct |
62 ms |
9096 KB |
Output is correct |
5 |
Correct |
74 ms |
9164 KB |
Output is correct |
6 |
Correct |
78 ms |
9576 KB |
Output is correct |
7 |
Correct |
95 ms |
11048 KB |
Output is correct |
8 |
Correct |
82 ms |
11576 KB |
Output is correct |
9 |
Correct |
52 ms |
7876 KB |
Output is correct |
10 |
Correct |
96 ms |
12072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
9840 KB |
Output is correct |
2 |
Correct |
96 ms |
11652 KB |
Output is correct |
3 |
Correct |
97 ms |
11564 KB |
Output is correct |
4 |
Correct |
94 ms |
11428 KB |
Output is correct |
5 |
Correct |
93 ms |
10336 KB |
Output is correct |
6 |
Correct |
93 ms |
11548 KB |
Output is correct |
7 |
Correct |
103 ms |
11584 KB |
Output is correct |
8 |
Correct |
110 ms |
12660 KB |
Output is correct |
9 |
Correct |
77 ms |
10316 KB |
Output is correct |
10 |
Correct |
94 ms |
11616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3252 KB |
Output is correct |
2 |
Correct |
6 ms |
3400 KB |
Output is correct |
3 |
Correct |
4 ms |
3180 KB |
Output is correct |
4 |
Correct |
4 ms |
3148 KB |
Output is correct |
5 |
Correct |
5 ms |
3144 KB |
Output is correct |
6 |
Correct |
5 ms |
3132 KB |
Output is correct |
7 |
Correct |
6 ms |
3300 KB |
Output is correct |
8 |
Correct |
5 ms |
3404 KB |
Output is correct |
9 |
Correct |
6 ms |
3400 KB |
Output is correct |
10 |
Correct |
6 ms |
3528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
11236 KB |
Output is correct - 120000 bits used |
2 |
Correct |
102 ms |
11440 KB |
Output is correct - 122000 bits used |
3 |
Correct |
94 ms |
11592 KB |
Output is correct - 125000 bits used |
4 |
Correct |
95 ms |
11548 KB |
Output is correct - 125000 bits used |
5 |
Correct |
104 ms |
11712 KB |
Output is correct - 125000 bits used |
6 |
Correct |
97 ms |
11540 KB |
Output is correct - 125000 bits used |
7 |
Correct |
93 ms |
11620 KB |
Output is correct - 124828 bits used |
8 |
Correct |
96 ms |
11772 KB |
Output is correct - 124910 bits used |
9 |
Correct |
102 ms |
11724 KB |
Output is correct - 125000 bits used |
10 |
Correct |
93 ms |
12788 KB |
Output is correct - 125000 bits used |