#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] != 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 |
Incorrect |
5 ms |
640 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
888 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 |
2529 ms |
1124 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
796 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 |
2545 ms |
1244 KB |
Time limit exceeded |
2 |
Execution timed out |
2536 ms |
1400 KB |
Time limit exceeded |
3 |
Execution timed out |
2515 ms |
1400 KB |
Time limit exceeded |
4 |
Execution timed out |
2553 ms |
1164 KB |
Time limit exceeded |
5 |
Execution timed out |
2528 ms |
1364 KB |
Time limit exceeded |
6 |
Execution timed out |
2531 ms |
1276 KB |
Time limit exceeded |
7 |
Execution timed out |
2559 ms |
1400 KB |
Time limit exceeded |
8 |
Execution timed out |
2549 ms |
1152 KB |
Time limit exceeded |
9 |
Execution timed out |
2562 ms |
1272 KB |
Time limit exceeded |
10 |
Execution timed out |
2537 ms |
1180 KB |
Time limit exceeded |