#include <bits/stdc++.h>
#include "advisor.h"
#define S second
using namespace std;
void appendint(int x,int len){
printf("%d\n",x);
for(int i=0;i<=len;i++)
WriteAdvice(((1<<i)&x)+'0');
}
const int N1 = 2e5+100;
int nxt[N1],last[N1];
vector<int>freq[N1];
map<int,int>pos;
void ComputeAdvice(int *C, int N, int K, int M) {
int len = 0;
for(int i=1;;i++){
if((1<<i)>K)break;
len = i;
}
int n = N;
for(int i=0;i<n;i++)
freq[C[i]].push_back(i);
for(int i=0;i<n;i++)
freq[i].push_back(n+100);
set<pair<int,int>>st;
set<int>st1;
for(int i=0;i<K;i++)
st.insert({freq[i][1],i}),st1.insert(i),pos[i] = i;
for(int i=0;i<n;i++){
if(st1.find(C[i])!=st1.end())
appendint(0,len);
else {
auto it = st.rbegin();
int val = (*it).S;
st1.erase(val);
st1.insert(C[i]);
pos[C[i]] = pos[val];
appendint(pos[val]+1,len);
st.erase(*it);
int nxt = upper_bound(freq[C[i]].begin(),freq[C[i]].end(),i)-freq[C[i]].begin();
nxt = freq[C[i]][nxt];
st.insert({nxt,C[i]});
}
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
int a[2000000],vals[2000000];
int get(int idx,int len){
int ret = 0;
for(int i=idx;i<idx+len;i++)
ret += (1<<(i-idx))*a[i];
return ret;
}
void Assist(unsigned char *A, int N, int K, int R) {
printf("%d\n",R);
for(int i=0;i<R;i++)
cout<<A[i];
int len = 0;
for(int i=0;;i++){
if((1<<i)>K)break;
len = i;
}
for(int i=0;i<K;i++)
vals[i] = i;
for(int i=0;i<R;i++)
a[i] = A[i]-'0';
int n = N;
for(int i=0;i<n;i++){
int val = GetRequest();
int val1 = get(i,len);
if(!val1)continue;
PutBack(vals[val1]);
vals[val1] = val;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
5240 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
5956 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
11752 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
5644 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
12724 KB |
Error - Invalid Access |
2 |
Incorrect |
44 ms |
13016 KB |
Error - Invalid Access |
3 |
Incorrect |
49 ms |
13424 KB |
Error - Invalid Access |
4 |
Incorrect |
47 ms |
13352 KB |
Error - Invalid Access |
5 |
Incorrect |
54 ms |
13388 KB |
Error - Invalid Access |
6 |
Incorrect |
46 ms |
13440 KB |
Error - Invalid Access |
7 |
Incorrect |
55 ms |
13464 KB |
Error - Invalid Access |
8 |
Incorrect |
78 ms |
13456 KB |
Error - Invalid Access |
9 |
Incorrect |
55 ms |
13380 KB |
Error - Invalid Access |
10 |
Incorrect |
47 ms |
13396 KB |
Error - Invalid Access |