#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
static int *C, N, K, M, B, D[MAXN+10], P[MAXN+10];
static vector<int> T[MAXN+10];
void ComputeAdvice(int *_C, int _N, int _K, int _M)
{
int i, j;
C=_C; N=_N; K=_K; M=_M;
for(i=20; i>=0; i--) if(N&(1<<i)) break;
B=i+1;
for(i=N-1; i>=0; i--) T[C[i]].push_back(i);
priority_queue<pii> PQ;
for(i=0; i<K; i++)
{
int p=i;
if(T[p].empty()) PQ.push({N, p});
else PQ.push({T[p].back(), p}), T[p].pop_back();
P[i]=1;
}
for(i=0; i<N; i++)
{
if(P[C[i]]) { D[i]=(1<<B)-1; continue; }
pii now=PQ.top(); PQ.pop();
D[i]=now.second; P[now.second]=0;
int p=C[i]; P[p]=1;
if(T[p].empty()) PQ.push({N, p});
else PQ.push({T[p].back(), p}), T[p].pop_back();
}
for(i=0; i<N; i++)
{
for(j=0; j<B; j++)
{
if(D[i]&(1<<j)) WriteAdvice(1);
else WriteAdvice(0);
}
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
static int N, K, R, B, D[MAXN+10];
unsigned char *A;
void Assist(unsigned char *_A, int _N, int _K, int _R)
{
int i, j;
A=_A; N=_N; K=_K; R=_R;
for(i=20; i>=0; i--) if(N&(1<<i)) break;
B=i+1;
int cnt=0;
for(i=0; i<N; i++) for(j=0; j<B; j++) if(A[cnt++]) D[i]|=(1<<j);
for(i=0; i<N; i++)
{
GetRequest();
if(D[i]!=(1<<B)-1) PutBack(D[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
5304 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
7152 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
325 ms |
21104 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
5960 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
407 ms |
24648 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
404 ms |
24720 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
402 ms |
24360 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
403 ms |
24424 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
405 ms |
24416 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
407 ms |
24352 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
407 ms |
24416 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
420 ms |
24592 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
406 ms |
24360 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
410 ms |
26464 KB |
Output isn't correct - not an optimal way |