#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#include "advisor.h"
const int INF = 1e9;
void ComputeAdvice(int *C, int N, int K, int M) {
vector<int> put_down;
vector<vector<int>> oc;
int log2 = 1;
while((1<<log2)<N){
log2++;
}
oc.resize(N);
for(int i = 0; i<N; i++){
oc[C[i]].push_back(i);
}
for(int i = 0; i<N; i++){
oc[i].push_back(INF);
reverse(oc[i].begin(), oc[i].end());
}
set<pii> cur_colors;
for(int i = 0; i<K; i++){
cur_colors.insert({oc[i].back(), i});
}
for(int i = 0; i<N; i++){
int needed = C[i];
if(cur_colors.find({oc[C[i]].back(), C[i]}) == cur_colors.end()){
pii removing = *(--cur_colors.end());
cur_colors.erase(removing);
put_down.push_back(removing.second);
}
else{
cur_colors.erase({oc[needed].back(), needed});
}
oc[needed].pop_back();
cur_colors.insert({oc[needed].back(), needed});
}
for(auto e: put_down){
for(int i = 0; i<log2; i++){
WriteAdvice((e&(1<<i))>>i);
}
}
}
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#include "assistant.h"
void Assist(unsigned char *A, int N, int K, int R) {
int i;
int log2 = 1;
while((1<<log2)<N){
log2++;
}
set<int> cur_colors;
for(int i = 0; i<K; i++){
cur_colors.insert(i);
}
vector<int> put_down;
for(int i =0; i<R; i+=log2){
int val = 0;
for(int j = 0; j<log2; j++){
val += A[j+i] * (1<<j);
}
put_down.push_back(val);
}
reverse(put_down.begin(), put_down.end());
for (i = 0; i < N; i++) {
int req = GetRequest();
if(cur_colors.find(req) == cur_colors.end()){
PutBack(put_down.back());
put_down.pop_back();
}
cur_colors.insert(req);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
776 KB |
Output is correct |
2 |
Correct |
1 ms |
944 KB |
Output is correct |
3 |
Correct |
1 ms |
792 KB |
Output is correct |
4 |
Incorrect |
6 ms |
1104 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
2284 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
13208 KB |
Output is correct |
2 |
Correct |
242 ms |
15860 KB |
Output is correct |
3 |
Correct |
215 ms |
16004 KB |
Output is correct |
4 |
Correct |
211 ms |
15168 KB |
Output is correct |
5 |
Incorrect |
166 ms |
13492 KB |
Error - Not putting back color when it is not on the scaffold |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1036 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
214 ms |
15832 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Correct |
209 ms |
15764 KB |
Output is partially correct - 841041 bits used |
3 |
Correct |
218 ms |
15712 KB |
Output is partially correct - 807466 bits used |
4 |
Correct |
212 ms |
15756 KB |
Output is partially correct - 806939 bits used |
5 |
Correct |
209 ms |
15692 KB |
Output is partially correct - 805358 bits used |
6 |
Correct |
225 ms |
15692 KB |
Output is partially correct - 807109 bits used |
7 |
Correct |
230 ms |
16096 KB |
Output is partially correct - 805902 bits used |
8 |
Correct |
213 ms |
15836 KB |
Output is partially correct - 808452 bits used |
9 |
Correct |
221 ms |
16264 KB |
Output is partially correct - 807874 bits used |
10 |
Incorrect |
286 ms |
19456 KB |
Error - Not putting back color when it is not on the scaffold |