#include "advisor.h"
#include<bits/stdc++.h>
#define pb emplace_back
#define pii pair<ll,ll>
#define all(n) (n).begin(),(n).end()
#define ll long long
using namespace std;
int pos[100005], bk[100005], in[100005];
void Write(int x,int N){
int mx = __lg(N);
vector<int> v;
for(int i=0;i<=mx;i++){
v.pb(x&1);
x>>=1;
}
reverse(all(v));
for(auto &i:v){
WriteAdvice(i);
}
}
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0;i<N;i++){
pos[i] = N+1;
}
for(int i=N-1;i>=0;i--){
bk[i] = pos[C[i]];
pos[C[i]] = i;
}
priority_queue<pii> pq;
for(int i=0;i<K;i++){
in[i] = 1;
pq.push({pos[i],i});
}
for(int i=0;i<N;i++){
if(in[C[i]]) continue;
else{
int x = pq.top().second; pq.pop();
pq.push({bk[i], C[i]});
in[C[i]] = 1, in[x] = 0;
Write(x,N);
}
}
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
int in2[100005];
void Assist(unsigned char *A, int N, int K, int R) {
int id = 0;
for(int i=0;i<K;i++) in2[i] = 1;
for(int i=0;i<N;i++){
int x = GetRequest();
if(in2[x]) continue;
int rm = 0;
for(int j=id;id<=j+__lg(N);id++){
rm = rm * 2 + A[id];
}
//cout<<"RM : "<<rm<<'\n';
PutBack(rm);
in2[rm] = 0;
in2[x] = 1;
}
assert(id <= R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1020 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1020 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
1792 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
252 ms |
10624 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1280 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
340 ms |
13424 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
321 ms |
13104 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
300 ms |
12576 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
297 ms |
12496 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
301 ms |
12496 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
303 ms |
12552 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
308 ms |
12504 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
300 ms |
12496 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
301 ms |
12488 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
362 ms |
14288 KB |
Output is partially correct - 1266636 bits used |