#include "advisor.h"
#include <vector>
void ComputeAdvice(int *C, int N, int K, int M) {
std::vector < int > viz(N, 0);
int timp = 0;
for (int i = 0; i < K; i++) {
int pos = 0, cnt = 0;
timp++;
while (pos < N && C[pos] != i) {
cnt += viz[C[pos]] != timp;
viz[C[pos]] = timp;
pos++;
}
WriteAdvice(pos < N && cnt < K);
}
for (int i = 0; i < N; i++) {
int pos = i + 1, cnt = 0;
timp++;
while (pos < N && C[pos] != C[i]) {
cnt += viz[C[pos]] != timp;
viz[C[pos]] = timp;
pos++;
}
WriteAdvice(pos < N && cnt < K);
}
}
#include "assistant.h"
#include <vector>
void Assist(unsigned char *A, int N, int K, int R) {
std::vector < int > v(K), t(N, 0);
for (int i = 0; i < K; i++)
v[i] = i, t[i] = A[i];
for (int i = 0; i < N; i++) {
int x = GetRequest();
int p = 0;
while (p < K && v[p] != x)
p++;
if (p >= K) {
p = 0;
while (t[v[p]])
p++;
PutBack(v[p]);
v[p] = x;
}
t[x] = A[i + K];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
640 KB |
Output is correct |
2 |
Incorrect |
4 ms |
768 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
80 ms |
1008 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2533 ms |
1132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
932 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2520 ms |
1288 KB |
Time limit exceeded |
2 |
Execution timed out |
2547 ms |
1272 KB |
Time limit exceeded |
3 |
Execution timed out |
2551 ms |
1400 KB |
Time limit exceeded |
4 |
Execution timed out |
2529 ms |
1276 KB |
Time limit exceeded |
5 |
Execution timed out |
2533 ms |
1372 KB |
Time limit exceeded |
6 |
Execution timed out |
2543 ms |
1244 KB |
Time limit exceeded |
7 |
Execution timed out |
2526 ms |
1272 KB |
Time limit exceeded |
8 |
Execution timed out |
2538 ms |
1276 KB |
Time limit exceeded |
9 |
Execution timed out |
2538 ms |
1152 KB |
Time limit exceeded |
10 |
Execution timed out |
2543 ms |
1244 KB |
Time limit exceeded |