#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});
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;
while(!T[p].empty() && T[p].back()<=i) T[p].pop_back();
if(T[p].empty()) PQ.push({N, p});
else PQ.push({T[p].back(), p});
}
//for(i=0; i<N; i++) printf("%d ", D[i]);
//printf("\n=========\n");
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]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
5360 KB |
Output is correct |
2 |
Incorrect |
6 ms |
5368 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
39 ms |
7152 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
315 ms |
20656 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
5616 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
405 ms |
24472 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
397 ms |
24456 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
400 ms |
24416 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
396 ms |
24408 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
393 ms |
24672 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
394 ms |
24664 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
394 ms |
24368 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
392 ms |
24672 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
393 ms |
24416 KB |
Output isn't correct - not an optimal way |
10 |
Correct |
407 ms |
26720 KB |
Output is partially correct - 1700000 bits used |