#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
using pii = pair<int, int>;
static const int N = 200010;
static const int INF = 1e9;
static int ptr[N], last[N], ans[N];
static vector<int> seqpos[N];
static set<pii> S;
static int getnext(int x) {
if (ptr[x] < (int)seqpos[x].size())
return seqpos[x][ptr[x]];
else
return INF;
}
static void movenext(int x) {
S.erase(pii(getnext(x), x));
++ptr[x];
S.insert(pii(getnext(x), x));
}
void ComputeAdvice(int *C, int n, int k, int m) {
for (int i = 0; i < n; ++i)
seqpos[C[i]].push_back(i);
for (int i = 0; i < k; ++i)
S.insert(pii(getnext(i), i)), last[i] = i;
for (int i = 0; i < n; ++i) {
int x = C[i];
if (S.count(pii(getnext(x), x))) {
//printf("found %d\n", x);
} else {
auto it = prev(S.end());
ans[last[it->second]] = 1;
//printf("threw away %d\n", it->second);
S.erase(it);
S.insert(pii(getnext(x), x));
}
movenext(x);
last[x] = k+i;
}
for (int i = 0; i < n+k; ++i)
WriteAdvice(ans[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int n, int k, int r) {
r = 0;
set<int> has;
deque<int> avail;
for (int i = 0; i < k; ++i) {
has.insert(i);
if (A[r++] == 1)
avail.push_back(i);
}
for (int i = 0; i < n; ++i) {
int x = GetRequest();
if (!has.count(x)) {
has.erase(avail.front());
PutBack(avail.front());
avail.pop_front();
has.insert(x);
}
if (A[r++] == 1)
avail.push_back(x);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
9968 KB |
Output is correct |
2 |
Correct |
10 ms |
10488 KB |
Output is correct |
3 |
Correct |
13 ms |
10568 KB |
Output is correct |
4 |
Correct |
12 ms |
10992 KB |
Output is correct |
5 |
Correct |
15 ms |
10992 KB |
Output is correct |
6 |
Correct |
19 ms |
10992 KB |
Output is correct |
7 |
Correct |
20 ms |
11040 KB |
Output is correct |
8 |
Correct |
16 ms |
11328 KB |
Output is correct |
9 |
Correct |
17 ms |
11328 KB |
Output is correct |
10 |
Correct |
19 ms |
11440 KB |
Output is correct |
11 |
Correct |
20 ms |
11440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
11744 KB |
Output is correct |
2 |
Correct |
118 ms |
14552 KB |
Output is correct |
3 |
Correct |
251 ms |
24576 KB |
Output is correct |
4 |
Correct |
187 ms |
24576 KB |
Output is correct |
5 |
Correct |
195 ms |
24576 KB |
Output is correct |
6 |
Correct |
249 ms |
24576 KB |
Output is correct |
7 |
Correct |
294 ms |
26488 KB |
Output is correct |
8 |
Correct |
186 ms |
28128 KB |
Output is correct |
9 |
Correct |
196 ms |
28128 KB |
Output is correct |
10 |
Correct |
372 ms |
30824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
30824 KB |
Output is correct |
2 |
Correct |
252 ms |
30824 KB |
Output is correct |
3 |
Correct |
390 ms |
31424 KB |
Output is correct |
4 |
Correct |
292 ms |
32344 KB |
Output is correct |
5 |
Correct |
317 ms |
32344 KB |
Output is correct |
6 |
Correct |
268 ms |
35008 KB |
Output is correct |
7 |
Correct |
330 ms |
36160 KB |
Output is correct |
8 |
Correct |
236 ms |
39360 KB |
Output is correct |
9 |
Correct |
264 ms |
39360 KB |
Output is correct |
10 |
Correct |
333 ms |
39648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
39648 KB |
Output is correct |
2 |
Correct |
17 ms |
39648 KB |
Output is correct |
3 |
Correct |
16 ms |
39648 KB |
Output is correct |
4 |
Correct |
14 ms |
39648 KB |
Output is correct |
5 |
Correct |
15 ms |
39648 KB |
Output is correct |
6 |
Correct |
18 ms |
39648 KB |
Output is correct |
7 |
Correct |
20 ms |
39648 KB |
Output is correct |
8 |
Correct |
19 ms |
39648 KB |
Output is correct |
9 |
Correct |
21 ms |
39648 KB |
Output is correct |
10 |
Correct |
17 ms |
39648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
292 ms |
39648 KB |
Output is correct - 120000 bits used |
2 |
Correct |
282 ms |
39648 KB |
Output is correct - 122000 bits used |
3 |
Correct |
297 ms |
39648 KB |
Output is correct - 125000 bits used |
4 |
Correct |
326 ms |
39784 KB |
Output is correct - 125000 bits used |
5 |
Correct |
291 ms |
39784 KB |
Output is correct - 125000 bits used |
6 |
Correct |
246 ms |
39784 KB |
Output is correct - 125000 bits used |
7 |
Correct |
284 ms |
39840 KB |
Output is correct - 124828 bits used |
8 |
Correct |
297 ms |
39840 KB |
Output is correct - 124910 bits used |
9 |
Correct |
300 ms |
39840 KB |
Output is correct - 125000 bits used |
10 |
Correct |
266 ms |
41832 KB |
Output is correct - 125000 bits used |