#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5;
int f[nmax + 1];
int lst[nmax + 1];
bool adv[2 * nmax + 1];
void ComputeAdvice(int *v, int N, int K, int M) {
for (int i = 0; i < N; ++ i)
lst[i] = 1 << 30;
int ind = N - 1;
int total = 0;
for (int i = N - 1; i >= 0; -- i) {
while (ind >= i && total > K) {
-- f[v[ind]];
if (f[v[ind]] == 0)
-- total;
-- ind;
}
if (total == K && lst[v[i]] > ind) {
adv[i + K] = 1;
}
if (f[v[i]] == 0)
++ total;
++ f[v[i]];
lst[v[i]] = i;
}
for (int i = K - 1; i >= 0; -- i) {
while (ind >= i && total > K) {
-- f[v[ind]];
if (f[v[ind]] == 0)
-- total;
-- ind;
}
if (total == K && lst[i] > ind) {
adv[i] = 1;
}
}
for (int i = 0; i < N + K; ++ i) {
WriteAdvice(adv[i]);
//cout << adv[i] << "\n";
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5;
bool viz[nmax + 1];
queue<int> q;
void Assist(unsigned char *A, int N, int K, int R) {
for (int i = 0; i < K; ++ i) {
viz[i] = 1;
if (A[i] == 1)
q.push(i);
}
for (int i = 0; i < N; ++ i) {
int c = GetRequest();
if (viz[c] == 0) {
assert(q.size());
PutBack(q.front());
viz[q.front()] = 0;
q.pop();
}
viz[c] = 1;
if (A[i + K] == 1)
q.push(c);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
864 KB |
Output is correct |
2 |
Incorrect |
5 ms |
772 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1284 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
5304 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1024 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
71 ms |
6256 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
82 ms |
6136 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
76 ms |
6400 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
70 ms |
6128 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
70 ms |
6128 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
59 ms |
6128 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
76 ms |
6496 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
69 ms |
6128 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
78 ms |
6392 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
64 ms |
6536 KB |
Output isn't correct - not an optimal way |