#include "advisor.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
static int A[202020], X[202020], R[101010];
static int B[202020];
static priority_queue<pii> PQ;
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i=0; i<K; i++) A[i]=i;
for (int i=0; i<N; i++) A[i+K]=C[i], R[i]=N+K;
for (int i=N+K-1; i>=0; i--) X[i]=R[A[i]], R[A[i]]=i;
memset(R, -1, sizeof R);
for (int i=0; i<K; i++) PQ.push(pii(X[i], i)), R[i]=i;
for (int i=K; i<K+N; i++){
if (R[A[i]]<0){
while (R[A[PQ.top().se]] != PQ.top().se) PQ.pop();
B[PQ.top().se]=1, R[A[PQ.top().se]]=-1;
PQ.pop();
}
R[A[i]]=i, PQ.push(pii(X[i], i));
}
for (int i=0; i<K+N; i++) WriteAdvice(B[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
static bool chk[101010];
static set<int> E;
void Assist(unsigned char *A, int N, int K, int R) {
for (int i=0; i<K; i++){
if (A[i]) E.insert(i);
chk[i]=true;
}
for (int i=0; i<N; i++){
int x=GetRequest();
if (!chk[x]) PutBack(*E.begin()), chk[*E.begin()]=false, E.erase(E.begin());
if (A[i+K]) E.insert(x);
else E.erase(x);
chk[x]=true;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1536 KB |
Output is correct |
2 |
Correct |
1 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
3 ms |
1536 KB |
Output is correct |
5 |
Correct |
4 ms |
1792 KB |
Output is correct |
6 |
Correct |
5 ms |
1792 KB |
Output is correct |
7 |
Correct |
10 ms |
1792 KB |
Output is correct |
8 |
Correct |
5 ms |
1792 KB |
Output is correct |
9 |
Correct |
5 ms |
1792 KB |
Output is correct |
10 |
Correct |
6 ms |
2048 KB |
Output is correct |
11 |
Correct |
5 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2368 KB |
Output is correct |
2 |
Correct |
43 ms |
4856 KB |
Output is correct |
3 |
Correct |
101 ms |
8664 KB |
Output is correct |
4 |
Correct |
80 ms |
6656 KB |
Output is correct |
5 |
Correct |
81 ms |
6896 KB |
Output is correct |
6 |
Correct |
88 ms |
7392 KB |
Output is correct |
7 |
Correct |
90 ms |
8408 KB |
Output is correct |
8 |
Correct |
76 ms |
7136 KB |
Output is correct |
9 |
Correct |
97 ms |
6640 KB |
Output is correct |
10 |
Correct |
104 ms |
8664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
7136 KB |
Output is correct |
2 |
Correct |
93 ms |
8408 KB |
Output is correct |
3 |
Correct |
89 ms |
8664 KB |
Output is correct |
4 |
Correct |
110 ms |
8664 KB |
Output is correct |
5 |
Correct |
86 ms |
8664 KB |
Output is correct |
6 |
Correct |
90 ms |
8408 KB |
Output is correct |
7 |
Correct |
90 ms |
8664 KB |
Output is correct |
8 |
Correct |
90 ms |
7904 KB |
Output is correct |
9 |
Correct |
100 ms |
8152 KB |
Output is correct |
10 |
Correct |
101 ms |
8664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1792 KB |
Output is correct |
2 |
Correct |
7 ms |
1792 KB |
Output is correct |
3 |
Correct |
5 ms |
1792 KB |
Output is correct |
4 |
Correct |
6 ms |
1792 KB |
Output is correct |
5 |
Correct |
6 ms |
1792 KB |
Output is correct |
6 |
Correct |
5 ms |
1696 KB |
Output is correct |
7 |
Correct |
5 ms |
1792 KB |
Output is correct |
8 |
Correct |
5 ms |
1792 KB |
Output is correct |
9 |
Correct |
6 ms |
1792 KB |
Output is correct |
10 |
Correct |
8 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
8360 KB |
Output is correct - 120000 bits used |
2 |
Correct |
109 ms |
8360 KB |
Output is correct - 122000 bits used |
3 |
Correct |
90 ms |
8664 KB |
Output is correct - 125000 bits used |
4 |
Correct |
91 ms |
8520 KB |
Output is correct - 125000 bits used |
5 |
Correct |
106 ms |
8664 KB |
Output is correct - 125000 bits used |
6 |
Correct |
101 ms |
8664 KB |
Output is correct - 125000 bits used |
7 |
Correct |
90 ms |
8408 KB |
Output is correct - 124828 bits used |
8 |
Correct |
105 ms |
8664 KB |
Output is correct - 124910 bits used |
9 |
Correct |
104 ms |
8672 KB |
Output is correct - 125000 bits used |
10 |
Correct |
91 ms |
8160 KB |
Output is correct - 125000 bits used |