#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);
set<pii, greater<pii>> PQ;
for(i=0; i<K; i++)
{
if(T[i].empty()) PQ.insert({N, i});
else PQ.insert({T[i].back(), i}), T[i].pop_back();
P[i]=1;
}
for(i=0; i<N; i++)
{
if(P[C[i]])
{
PQ.erase({C[i], i});
if(T[C[i]].empty()) PQ.insert({N, C[i]});
else PQ.insert({T[C[i]].back(), C[i]}), T[C[i]].pop_back();
D[i]=(1<<B)-1;
}
else
{
D[i]=PQ.begin()->second;
P[PQ.begin()->second]=0;
PQ.erase(PQ.begin());
if(T[C[i]].empty()) PQ.insert({N, C[i]});
else PQ.insert({T[C[i]].back(), C[i]}), T[C[i]].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 |
5360 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
7152 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
343 ms |
22792 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
5816 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
424 ms |
26424 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
431 ms |
26864 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
428 ms |
27376 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
428 ms |
27384 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
431 ms |
27304 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
435 ms |
27376 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
436 ms |
27416 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
428 ms |
27344 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
434 ms |
27496 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
429 ms |
29680 KB |
Error - Putting back a color when it is already on the scaffold |