#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
set<pair<int,int>>st;
set<int>wtf;
int n,k,m,lgk;
int allk[maxn],nxt[maxn],last[maxn],go[maxn],wh[maxn];
void wri(int x){
for(int i=0;i<=lgk;i++){
WriteAdvice((x>>i)&1);
}
}
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0;i<20;i++){
if((K>>i)&1){
lgk=i;
}
}
n=N;
k=K;
m=M;
for(int i=0;i<maxn;i++){
last[i]=n+1;
}
for(int i=n-1;i>=0;i--){
nxt[i]=last[C[i]];
last[C[i]]=i;
}
for(int i=0;i<k;i++){
allk[i]=i;
wtf.insert(i);
go[i]=last[allk[i]];
wh[i]=i;
st.insert(make_pair(last[allk[i]],i));
}
for(int i=0;i<N;i++){
if(wtf.count(C[i])==1){
st.erase(make_pair(go[wh[C[i]]],wh[C[i]]));
go[wh[C[i]]]=nxt[i];
st.insert(make_pair(nxt[i],wh[C[i]]));
continue;
}
int z=(*st.rbegin()).second;
wri(z);
st.erase((*st.rbegin()));
wtf.erase(allk[z]);
wh[C[i]]=z;
go[z]=nxt[i];
allk[z]=C[i];
wtf.insert(C[i]);
st.insert(make_pair(nxt[i],z));
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int all[maxn],lgk2,n2,k2,r2;
set<int>st2;
void Assist(unsigned char *A, int N, int K, int R) {
for(int i=0;i<20;i++){
if((K>>i)&1){
lgk2=i;
}
}
n2=N;
k2=K;
r2=R;
for(int i=0;i<k2;i++){
all[i]=i;
st2.insert(i);
}
int unnow=0;
for(int i=0;i<n2;i++){
int req=GetRequest();
if(st2.count(req)==1){
continue;
}
int x=0;
if(unnow>=R){
assert(0);
}
for(int i=0;i<=lgk2;i++){
if(A[unnow]==1){
x+=(1<<i);
}
unnow++;
}
PutBack(all[x]);
st2.erase(all[x]);
all[x]=req;
st2.insert(req);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1296 KB |
Output is correct |
2 |
Correct |
1 ms |
1308 KB |
Output is correct |
3 |
Correct |
1 ms |
1296 KB |
Output is correct |
4 |
Correct |
3 ms |
1328 KB |
Output is correct |
5 |
Correct |
3 ms |
1332 KB |
Output is correct |
6 |
Correct |
7 ms |
1380 KB |
Output is correct |
7 |
Correct |
3 ms |
1328 KB |
Output is correct |
8 |
Correct |
7 ms |
1656 KB |
Output is correct |
9 |
Correct |
7 ms |
1464 KB |
Output is correct |
10 |
Correct |
6 ms |
1620 KB |
Output is correct |
11 |
Correct |
6 ms |
1844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2240 KB |
Output is correct |
2 |
Correct |
59 ms |
4704 KB |
Output is correct |
3 |
Correct |
192 ms |
14716 KB |
Output is correct |
4 |
Correct |
109 ms |
7376 KB |
Output is correct |
5 |
Correct |
141 ms |
9320 KB |
Output is correct |
6 |
Correct |
169 ms |
10512 KB |
Output is correct |
7 |
Correct |
166 ms |
11828 KB |
Output is correct |
8 |
Correct |
156 ms |
12496 KB |
Output is correct |
9 |
Correct |
75 ms |
6144 KB |
Output is correct |
10 |
Correct |
190 ms |
12328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
9496 KB |
Output is correct |
2 |
Correct |
170 ms |
11868 KB |
Output is correct |
3 |
Correct |
175 ms |
11912 KB |
Output is correct |
4 |
Correct |
162 ms |
11360 KB |
Output is correct |
5 |
Correct |
139 ms |
9848 KB |
Output is correct |
6 |
Correct |
170 ms |
11924 KB |
Output is correct |
7 |
Correct |
166 ms |
11596 KB |
Output is correct |
8 |
Correct |
196 ms |
14212 KB |
Output is correct |
9 |
Correct |
117 ms |
9824 KB |
Output is correct |
10 |
Correct |
164 ms |
12060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1296 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
11532 KB |
Output is partially correct - 772365 bits used |
2 |
Correct |
185 ms |
11628 KB |
Output is partially correct - 742095 bits used |
3 |
Correct |
187 ms |
12188 KB |
Output is partially correct - 712470 bits used |
4 |
Correct |
174 ms |
11756 KB |
Output is partially correct - 712005 bits used |
5 |
Correct |
202 ms |
12084 KB |
Output is partially correct - 710610 bits used |
6 |
Correct |
176 ms |
11924 KB |
Output is partially correct - 712155 bits used |
7 |
Correct |
161 ms |
11688 KB |
Output is partially correct - 711090 bits used |
8 |
Correct |
179 ms |
12112 KB |
Output is partially correct - 713340 bits used |
9 |
Correct |
196 ms |
12108 KB |
Output is partially correct - 712830 bits used |
10 |
Correct |
193 ms |
14268 KB |
Output is partially correct - 1117620 bits used |