#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i=0;i<N;i++){
int x = C[i];
for (int j = 19; j >= 0; j--){
if (((x >> j) & 1)) WriteAdvice(1);
else WriteAdvice(0);
}
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
const int MM = 2e6 + 5;
int CC[MM];
bool on[MM];
set <int> st[MM];
void Assist(unsigned char *A, int N, int K, int R) {
int id=0;
for (int i = 0; i < R; i += 20){
for (int j = i; j <= i + 19; j++){
if (A[j] == 1) CC[id] |= (1<<(19-(j-i)));
}
id+=1;
}
for (int i=id-1;i>=0;i--){
st[CC[i]].insert(i);
}
set <pair<int,int> > stt;
for (int i=0;i<K;i++){
on[i] = 1;
int val = 0;
if (!st[i].size()) val=1e9;
else val=*st[i].begin();
stt.insert({val,i});
}
int i;
for (i = 0; i < N; i++) {
int req = GetRequest();
if (on[req]) {
int val = 0;
if (!st[req].size()) val=1e9;
else val=*st[req].begin();
stt.erase(stt.find({val,req}));
while (st[req].size() && *st[req].begin() <= i){
st[req].erase(st[req].begin());
}
val = 0;
if (!st[req].size()) val=1e9;
else val=*st[req].begin();
stt.insert({val,req});
continue;
}
int idx=(--stt.end())->second;
PutBack(idx);
on[idx] = 0;
stt.erase(--stt.end());
on[req] = 1;
while (st[req].size() && *st[req].begin() <= i){
st[req].erase(st[req].begin());
}
int val = 0;
if (!st[req].size()) val=1e9;
else val=*st[req].begin();
stt.insert({val,req});
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
94732 KB |
Output is correct |
2 |
Correct |
30 ms |
94760 KB |
Output is correct |
3 |
Correct |
38 ms |
94780 KB |
Output is correct |
4 |
Correct |
37 ms |
95356 KB |
Output is correct |
5 |
Incorrect |
31 ms |
94648 KB |
Error - advice is too long |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
96720 KB |
Output is correct |
2 |
Correct |
164 ms |
105008 KB |
Output is correct |
3 |
Correct |
289 ms |
116428 KB |
Output is correct |
4 |
Correct |
281 ms |
114744 KB |
Output is correct |
5 |
Correct |
283 ms |
114924 KB |
Output is correct |
6 |
Correct |
314 ms |
115212 KB |
Output is correct |
7 |
Correct |
294 ms |
115696 KB |
Output is correct |
8 |
Correct |
247 ms |
112984 KB |
Output is correct |
9 |
Correct |
281 ms |
116272 KB |
Output is correct |
10 |
Correct |
299 ms |
116196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
43 ms |
97304 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
94672 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
46 ms |
98172 KB |
Error - advice is too long |
2 |
Incorrect |
51 ms |
98040 KB |
Error - advice is too long |
3 |
Incorrect |
53 ms |
97996 KB |
Error - advice is too long |
4 |
Incorrect |
45 ms |
98084 KB |
Error - advice is too long |
5 |
Incorrect |
46 ms |
97920 KB |
Error - advice is too long |
6 |
Incorrect |
48 ms |
98096 KB |
Error - advice is too long |
7 |
Incorrect |
46 ms |
98184 KB |
Error - advice is too long |
8 |
Incorrect |
46 ms |
97936 KB |
Error - advice is too long |
9 |
Incorrect |
45 ms |
98064 KB |
Error - advice is too long |
10 |
Incorrect |
46 ms |
98092 KB |
Error - advice is too long |