#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100005;
#define pii pair<int,int>
#define fi first
#define se second
int lst[maxn],nxt[maxn];
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0;i<N;i++) lst[i]=N;
for(int i=N-1;i>=0;i--){
nxt[i]=lst[C[i]];
lst[C[i]]=i;
}
set<pii> s;
for(int i=0;i<K;i++) s.insert({lst[i],i});
vector<int> c(N+1,0);
for(int i=0;i<N;i++){
if(s.find({i,C[i]})!=s.end()) c[i]=1,s.erase({i,C[i]});
else s.erase(*s.rbegin());
s.insert({nxt[i],C[i]});
}
for(int i=0;i<K;i++) WriteAdvice(c[lst[i]]);
for(int i=0;i<N;i++) WriteAdvice(c[nxt[i]]);
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
set<int> d0,d1;
for(int i=0;i<K;i++){
if(A[i]) d1.insert(i);
else d0.insert(i);
}
for(int i=0;i<N;i++){
int x=GetRequest();
if(d1.find(x)!=d1.end()) d1.erase(x);
else{
PutBack(*d0.begin());
d0.erase(d0.begin());
}
if(A[K+i]) d1.insert(x);
else d0.insert(x);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
796 KB |
Output is correct |
2 |
Correct |
0 ms |
784 KB |
Output is correct |
3 |
Correct |
2 ms |
800 KB |
Output is correct |
4 |
Correct |
2 ms |
812 KB |
Output is correct |
5 |
Correct |
3 ms |
820 KB |
Output is correct |
6 |
Correct |
3 ms |
820 KB |
Output is correct |
7 |
Correct |
4 ms |
828 KB |
Output is correct |
8 |
Correct |
4 ms |
1088 KB |
Output is correct |
9 |
Correct |
4 ms |
820 KB |
Output is correct |
10 |
Correct |
5 ms |
1088 KB |
Output is correct |
11 |
Correct |
5 ms |
1080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1132 KB |
Output is correct |
2 |
Correct |
46 ms |
2944 KB |
Output is correct |
3 |
Correct |
102 ms |
7704 KB |
Output is correct |
4 |
Correct |
50 ms |
4264 KB |
Output is correct |
5 |
Correct |
60 ms |
4164 KB |
Output is correct |
6 |
Correct |
75 ms |
4792 KB |
Output is correct |
7 |
Correct |
100 ms |
6072 KB |
Output is correct |
8 |
Correct |
76 ms |
5936 KB |
Output is correct |
9 |
Correct |
52 ms |
3904 KB |
Output is correct |
10 |
Correct |
106 ms |
7080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
80 ms |
5140 KB |
Output is correct |
2 |
Correct |
99 ms |
6596 KB |
Output is correct |
3 |
Correct |
101 ms |
6580 KB |
Output is correct |
4 |
Correct |
109 ms |
6532 KB |
Output is correct |
5 |
Correct |
105 ms |
5984 KB |
Output is correct |
6 |
Correct |
100 ms |
6592 KB |
Output is correct |
7 |
Correct |
109 ms |
6524 KB |
Output is correct |
8 |
Correct |
78 ms |
6604 KB |
Output is correct |
9 |
Correct |
94 ms |
6524 KB |
Output is correct |
10 |
Correct |
103 ms |
6584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
824 KB |
Output is correct |
2 |
Correct |
4 ms |
1084 KB |
Output is correct |
3 |
Correct |
3 ms |
820 KB |
Output is correct |
4 |
Correct |
3 ms |
828 KB |
Output is correct |
5 |
Correct |
4 ms |
828 KB |
Output is correct |
6 |
Correct |
3 ms |
820 KB |
Output is correct |
7 |
Correct |
4 ms |
820 KB |
Output is correct |
8 |
Correct |
4 ms |
1072 KB |
Output is correct |
9 |
Correct |
6 ms |
1084 KB |
Output is correct |
10 |
Correct |
6 ms |
1340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
6000 KB |
Output is correct - 120000 bits used |
2 |
Correct |
97 ms |
6332 KB |
Output is correct - 122000 bits used |
3 |
Correct |
105 ms |
6624 KB |
Output is correct - 125000 bits used |
4 |
Correct |
100 ms |
6756 KB |
Output is correct - 125000 bits used |
5 |
Correct |
105 ms |
6552 KB |
Output is correct - 125000 bits used |
6 |
Correct |
100 ms |
6784 KB |
Output is correct - 125000 bits used |
7 |
Correct |
100 ms |
6532 KB |
Output is correct - 124828 bits used |
8 |
Correct |
106 ms |
6360 KB |
Output is correct - 124910 bits used |
9 |
Correct |
100 ms |
6568 KB |
Output is correct - 125000 bits used |
10 |
Correct |
84 ms |
6592 KB |
Output is correct - 125000 bits used |