#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> pii;
static int P[151515], K[151515];
static priority_queue <pii> Q;
static bool chk[151515], ans[151515];
void ComputeAdvice(int *C, int n, int k, int m)
{
int i, t, x;
for(i=0; i<n; i++) P[i] = n + k + 1;
for(i=n-1; i>=0; i--){
K[k + i] = P[C[i]];
P[C[i]] = k + i;
}
for(i=0; i<k; i++){
K[i] = P[i];
P[i] = i; chk[i] = 1;
Q.push(pii(K[i], i));
}
for(i=0; i<n; i++){
if(!chk[C[i]]){
for(; ;){
t = Q.top().second; Q.pop();
x = t >= k? C[t - k] : t;
if(chk[x]){
chk[x] = 0; ans[t] = 1;
break;
}
}
Q.pop();
chk[C[i]] = 1;
}
Q.push(pii(K[k + i], k + i));
}
for(i=0; i<n+k; i++){
WriteAdvice(ans[i]);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
static vector <int> V;
static bool chk[101010];
void Assist(unsigned char *A, int n, int k, int r)
{
int i, c;
for(i=0; i<k; i++){
if(A[i]) V.push_back(i);
chk[i] = 1;
}
for(i=0; i<n; i++){
c = GetRequest();
if(!chk[c]){
chk[V.back()] = 0;
PutBack(V.back());
V.pop_back();
}
if(A[k + i]) V.push_back(c);
chk[c] = 1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
608 KB |
Output is correct |
2 |
Incorrect |
4 ms |
824 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2550 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
5800 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
5800 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 |
2535 ms |
2900 KB |
Time limit exceeded |
2 |
Execution timed out |
2583 ms |
2900 KB |
Time limit exceeded |
3 |
Incorrect |
115 ms |
6592 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
100 ms |
6600 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
122 ms |
6968 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
109 ms |
6968 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
100 ms |
6992 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
93 ms |
6992 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
108 ms |
6992 KB |
Output isn't correct - not an optimal way |
10 |
Execution timed out |
2560 ms |
3496 KB |
Time limit exceeded |