#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz(x) (int)(x.size())
typedef pair<int,int> ii;
const int INF = (int)(1e9);
vector<int> vec[100005];
int occ[100005];
set<ii,greater<ii> > myset;
int pos[100005],in[100005];
void ComputeAdvice(int *C, int N, int K, int M) {
int l=31-__builtin_clz(N+1)+1;
//cerr<<l<<"qldakjlsnjk\n";
for (int i = 0; i < N; ++i)
{
occ[i]=sz(vec[C[i]]);
vec[C[i]].push_back(i);
}
for (int i = 0; i < K; ++i){
in[i]=1;
if(!sz(vec[i]))myset.insert({INF,i});
else myset.insert({vec[i][0],i});
}
vector<int> code;
for (int i = 0; i < N; ++i)
{
if(in[C[i]]){
myset.erase({i,C[i]});
if((occ[i]+1)<sz(vec[C[i]]))myset.insert({vec[C[i]][occ[i]+1],C[i]});
else myset.insert({INF,C[i]});
}
else{
//cerr<<C[i]<<"\n";
ii h=*myset.begin();
myset.erase(myset.begin());
//cerr<<h.se<<"**\n";
assert(in[h.se]==1);
code.push_back(h.se);
in[h.se]=0,in[C[i]]=1;
if((occ[i]+1)<sz(vec[C[i]]))myset.insert({vec[C[i]][occ[i]+1],C[i]});
else myset.insert({INF,C[i]});
}
assert(sz(myset)==K);
/*for(auto it:myset){
cerr<<it.fi<<","<<it.se<<"\n";
}
cerr<<"--------\n";*/
}
//cerr<<l<<" ";
for(auto it:code){
//cerr<<it<<" ";
for (int i = 0; i < l; ++i){
//cerr<<((it>>i)&1)<<" ";
WriteAdvice(((it>>i)&1));
}
//cerr<<"\n";
}
//cerr<<"\n";
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz(x) (int)(x.size())
typedef pair<int,int> ii;
const int INF = (int)(1e9);
int tab[100005],here[100005];
void Assist(unsigned char *A, int N, int K, int R) {
int l=31-__builtin_clz(N+1)+1;
for (int i = 0; i < K; ++i)
tab[i]=i,here[i]=1;
assert(!(R%l));
vector<int> vec;
for (int i = 0; i < R; i+=l)
{
int nb=0;
for (int j = 0; j < l; ++j)
if(A[i+j]==1)nb+=(1<<j);
vec.push_back(nb);
}
int idx=0;
for (int i = 0; i < N; ++i)
{
int h=GetRequest();
if(!here[h]){
assert(idx<sz(vec));
here[vec[idx]]=0;
here[h]=1;
PutBack(vec[idx]),idx++;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
5376 KB |
Output is correct |
2 |
Correct |
2 ms |
5120 KB |
Output is correct |
3 |
Correct |
5 ms |
5376 KB |
Output is correct |
4 |
Correct |
11 ms |
5632 KB |
Output is correct |
5 |
Correct |
20 ms |
6144 KB |
Output is correct |
6 |
Correct |
17 ms |
6144 KB |
Output is correct |
7 |
Correct |
9 ms |
5888 KB |
Output is correct |
8 |
Correct |
18 ms |
6400 KB |
Output is correct |
9 |
Correct |
16 ms |
6144 KB |
Output is correct |
10 |
Correct |
12 ms |
6144 KB |
Output is correct |
11 |
Correct |
13 ms |
6144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
6912 KB |
Output is correct |
2 |
Correct |
119 ms |
11592 KB |
Output is correct |
3 |
Correct |
340 ms |
24864 KB |
Output is correct |
4 |
Correct |
420 ms |
24288 KB |
Output is correct |
5 |
Correct |
399 ms |
23496 KB |
Output is correct |
6 |
Correct |
341 ms |
22184 KB |
Output is correct |
7 |
Correct |
290 ms |
21816 KB |
Output is correct |
8 |
Correct |
302 ms |
23312 KB |
Output is correct |
9 |
Correct |
397 ms |
21248 KB |
Output is correct |
10 |
Correct |
267 ms |
21648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
221 ms |
17376 KB |
Output is correct |
2 |
Correct |
277 ms |
21608 KB |
Output is correct |
3 |
Correct |
279 ms |
21624 KB |
Output is correct |
4 |
Correct |
264 ms |
20896 KB |
Output is correct |
5 |
Correct |
222 ms |
17912 KB |
Output is correct |
6 |
Correct |
283 ms |
21368 KB |
Output is correct |
7 |
Correct |
276 ms |
21120 KB |
Output is correct |
8 |
Correct |
382 ms |
26520 KB |
Output is correct |
9 |
Correct |
216 ms |
16944 KB |
Output is correct |
10 |
Correct |
304 ms |
21360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
5632 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
286 ms |
20560 KB |
Output is partially correct - 875347 bits used |
2 |
Correct |
283 ms |
20408 KB |
Output is partially correct - 841041 bits used |
3 |
Correct |
300 ms |
20336 KB |
Output is partially correct - 807466 bits used |
4 |
Correct |
285 ms |
20304 KB |
Output is partially correct - 806939 bits used |
5 |
Correct |
311 ms |
20352 KB |
Output is partially correct - 805358 bits used |
6 |
Correct |
296 ms |
20344 KB |
Output is partially correct - 807109 bits used |
7 |
Correct |
273 ms |
20344 KB |
Output is partially correct - 805902 bits used |
8 |
Correct |
283 ms |
20344 KB |
Output is partially correct - 808452 bits used |
9 |
Correct |
319 ms |
20336 KB |
Output is partially correct - 807874 bits used |
10 |
Correct |
359 ms |
25264 KB |
Output is partially correct - 1266636 bits used |