#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#include "advisor.h"
deque<int> pl[100005];
vector<int> seq;
set<pii> pq;
bitset<100005> inq;
int nw[100005];
void ComputeAdvice(int *C, int N, int K, int M)
{
int L=__lg(K),cnt=0;
for(int i=0;i<N;++i)
pl[C[i]].pb(i);
for(int i=0;i<N;++i)
pl[i].pb(N);
for(int i=0;i<K;++i)
inq[i]=1,pq.insert(MP(pl[i][0],i)),nw[i]=i;
for(int i=0;i<N;++i)
if(inq[C[i]]) pq.erase(MP(i,C[i])),pl[C[i]].pop_front(),pq.insert(MP(pl[C[i]][0],C[i]));
else
{
auto tmp=--pq.end();
seq.pb(nw[tmp->S]),inq[tmp->S]=0,nw[C[i]]=nw[tmp->S],pq.erase(tmp),pl[C[i]].pop_front();
pq.insert(MP(pl[C[i]][0],C[i])),inq[C[i]]=1;
}
//for(int i:seq)
// cout << i << " ";
//ET;
for(int i:seq)
for(int j=1<<L;j;j>>=1)
WriteAdvice((bool)(i&j)),++cnt;
//cout << cnt << "\n";
//cout << "start!\n";
}
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#include "assistant.h"
int nnw[100005],rrel[100005];
void Assist(unsigned char *A, int N, int K, int R)
{
int L=__lg(K)+1,tp=0;
for(int i=0;i<K;++i)
nnw[i]=i,rrel[i]=i;
for(int i=0;i<N;++i)
{
int cur=GetRequest();
if(rrel[nnw[cur]]!=cur)
{
int tmp=0;
for(int i=tp;i<tp+L;++i)
tmp=tmp<<1|A[i];
tp+=L;
PutBack(rrel[tmp]),rrel[tmp]=cur,nnw[cur]=tmp;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
135408 KB |
Output is correct |
2 |
Correct |
63 ms |
135152 KB |
Output is correct |
3 |
Correct |
65 ms |
135408 KB |
Output is correct |
4 |
Correct |
80 ms |
135408 KB |
Output is correct |
5 |
Correct |
74 ms |
135664 KB |
Output is correct |
6 |
Correct |
85 ms |
136064 KB |
Output is correct |
7 |
Correct |
79 ms |
135408 KB |
Output is correct |
8 |
Correct |
87 ms |
135920 KB |
Output is correct |
9 |
Correct |
84 ms |
135920 KB |
Output is correct |
10 |
Correct |
72 ms |
135920 KB |
Output is correct |
11 |
Correct |
86 ms |
135824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
136376 KB |
Output is correct |
2 |
Correct |
167 ms |
139616 KB |
Output is correct |
3 |
Correct |
351 ms |
148712 KB |
Output is correct |
4 |
Correct |
259 ms |
143592 KB |
Output is correct |
5 |
Correct |
336 ms |
145640 KB |
Output is correct |
6 |
Correct |
329 ms |
146408 KB |
Output is correct |
7 |
Correct |
311 ms |
146408 KB |
Output is correct |
8 |
Correct |
343 ms |
146912 KB |
Output is correct |
9 |
Correct |
197 ms |
142824 KB |
Output is correct |
10 |
Correct |
316 ms |
146664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
284 ms |
144104 KB |
Output is correct |
2 |
Correct |
319 ms |
146160 KB |
Output is correct |
3 |
Correct |
398 ms |
146600 KB |
Output is correct |
4 |
Correct |
326 ms |
146152 KB |
Output is correct |
5 |
Correct |
269 ms |
144344 KB |
Output is correct |
6 |
Correct |
326 ms |
146464 KB |
Output is correct |
7 |
Correct |
318 ms |
146304 KB |
Output is correct |
8 |
Correct |
358 ms |
148952 KB |
Output is correct |
9 |
Correct |
256 ms |
144360 KB |
Output is correct |
10 |
Correct |
304 ms |
146600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
69 ms |
135600 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
318 ms |
146184 KB |
Output is partially correct - 772365 bits used |
2 |
Partially correct |
326 ms |
146336 KB |
Output is partially correct - 742095 bits used |
3 |
Partially correct |
323 ms |
146400 KB |
Output is partially correct - 712470 bits used |
4 |
Partially correct |
324 ms |
146608 KB |
Output is partially correct - 712005 bits used |
5 |
Partially correct |
316 ms |
146240 KB |
Output is partially correct - 710610 bits used |
6 |
Partially correct |
314 ms |
146400 KB |
Output is partially correct - 712155 bits used |
7 |
Partially correct |
304 ms |
146448 KB |
Output is partially correct - 711090 bits used |
8 |
Partially correct |
300 ms |
146408 KB |
Output is partially correct - 713340 bits used |
9 |
Partially correct |
307 ms |
146648 KB |
Output is partially correct - 712830 bits used |
10 |
Partially correct |
358 ms |
149208 KB |
Output is partially correct - 1117620 bits used |