#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000;
set<pair<int,int>>st;
set<int>wtf;
int n,k,m,lgk;
int allk[maxn],nxt[maxn],last[maxn],go[maxn],wh[maxn],ret[maxn*2],tof[maxn*2];
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;
tof[i]=i;
st.insert(make_pair(last[allk[i]],i));
}
for(int i=0;i<N;i++){
if(wtf.count(C[i])==1){
tof[wh[C[i]]]=i+k;
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]);
ret[tof[z]]=1;
tof[z]=i+k;
wh[C[i]]=z;
go[z]=nxt[i];
allk[z]=C[i];
wtf.insert(C[i]);
st.insert(make_pair(nxt[i],z));
}
for(int i=0;i<n*2;i++){
WriteAdvice(ret[i]);
}
}
#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) {
//cout<<"ajab: "<<R<<endl;
//for(int i=0;i<R;i++){
//cout<<(int)A[i]<<" ";
//}
//cout<<"\n";
for(int i=0;i<20;i++){
if((K>>i)&1){
lgk2=i;
}
}
n2=N;
k2=K;
r2=R;
vector<int>khor;
for(int i=0;i<k2;i++){
all[i]=i;
st2.insert(i);
if(A[i]==1){
khor.push_back(i);
}
}
int now=k2;
int unnow=0;
for(int i=0;i<n2;i++){
int req=GetRequest();
if(st2.count(req)==1){
if(A[now]==0){
//hehe
}else{
khor.push_back(req);
}
now++;
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(khor.back());
st2.erase(khor.back());
//cout<<"gahbl: "<<(int)khor.size()<<endl;
//cout<<"wtf: "<<khor.back()<<endl;
khor.pop_back();
st2.insert(req);
if(A[now]==0){
//hehe
}else{
khor.push_back(req);
}
now++;
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:43:9: warning: unused variable 'x' [-Wunused-variable]
43 | int x=0;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1308 KB |
Output is correct |
2 |
Correct |
1 ms |
1304 KB |
Output is correct |
3 |
Correct |
1 ms |
1320 KB |
Output is correct |
4 |
Correct |
3 ms |
1352 KB |
Output is correct |
5 |
Correct |
3 ms |
1376 KB |
Output is correct |
6 |
Correct |
4 ms |
1492 KB |
Output is correct |
7 |
Correct |
3 ms |
1368 KB |
Output is correct |
8 |
Correct |
4 ms |
1632 KB |
Output is correct |
9 |
Correct |
5 ms |
1616 KB |
Output is correct |
10 |
Correct |
6 ms |
1624 KB |
Output is correct |
11 |
Correct |
5 ms |
1632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2228 KB |
Output is correct |
2 |
Correct |
49 ms |
4544 KB |
Output is correct |
3 |
Correct |
133 ms |
12212 KB |
Output is correct |
4 |
Correct |
62 ms |
6868 KB |
Output is correct |
5 |
Correct |
79 ms |
6860 KB |
Output is correct |
6 |
Correct |
99 ms |
7636 KB |
Output is correct |
7 |
Correct |
107 ms |
9940 KB |
Output is correct |
8 |
Correct |
84 ms |
9560 KB |
Output is correct |
9 |
Correct |
59 ms |
6688 KB |
Output is correct |
10 |
Correct |
126 ms |
11628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
8604 KB |
Output is correct |
2 |
Correct |
129 ms |
10460 KB |
Output is correct |
3 |
Correct |
119 ms |
10724 KB |
Output is correct |
4 |
Correct |
123 ms |
10712 KB |
Output is correct |
5 |
Correct |
111 ms |
10092 KB |
Output is correct |
6 |
Correct |
117 ms |
10708 KB |
Output is correct |
7 |
Correct |
115 ms |
10772 KB |
Output is correct |
8 |
Correct |
92 ms |
10700 KB |
Output is correct |
9 |
Correct |
115 ms |
10456 KB |
Output is correct |
10 |
Correct |
115 ms |
10620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1356 KB |
Output is correct |
2 |
Correct |
6 ms |
1728 KB |
Output is correct |
3 |
Correct |
4 ms |
1372 KB |
Output is correct |
4 |
Correct |
3 ms |
1376 KB |
Output is correct |
5 |
Correct |
4 ms |
1364 KB |
Output is correct |
6 |
Correct |
5 ms |
1372 KB |
Output is correct |
7 |
Correct |
5 ms |
1376 KB |
Output is correct |
8 |
Correct |
4 ms |
1624 KB |
Output is correct |
9 |
Correct |
5 ms |
1624 KB |
Output is correct |
10 |
Correct |
6 ms |
2144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
9996 KB |
Output is correct - 200000 bits used |
2 |
Correct |
122 ms |
10192 KB |
Output is correct - 200000 bits used |
3 |
Correct |
121 ms |
10720 KB |
Output is correct - 200000 bits used |
4 |
Correct |
124 ms |
10696 KB |
Output is correct - 200000 bits used |
5 |
Correct |
123 ms |
10712 KB |
Output is correct - 200000 bits used |
6 |
Correct |
121 ms |
10852 KB |
Output is correct - 200000 bits used |
7 |
Correct |
140 ms |
10708 KB |
Output is correct - 199678 bits used |
8 |
Correct |
126 ms |
10712 KB |
Output is correct - 200000 bits used |
9 |
Correct |
123 ms |
10744 KB |
Output is correct - 200000 bits used |
10 |
Correct |
118 ms |
10968 KB |
Output is correct - 200000 bits used |