#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF 1e9
struct nodo
{
int v, p;
bool operator < ( const nodo & a ) const
{
return a.p > p;
}
};
bool activo[MAX];
int aparicion[MAX];
int sig[MAX];
int maxbits;
priority_queue < nodo > q;
void empuja( int x )
{
for( int i = maxbits - 1; i >= 0; i -- )
{
if( x & ( 1 << i ) )
WriteAdvice( 1 );
else
WriteAdvice( 0 );
}
}
void ComputeAdvice(int *C, int N, int K, int M) {
maxbits = ( int ) ceil( log2( N ) );
for( int i = 0; i < N; i ++ )
aparicion[i] = INF;
for( int i = N-1; i >= 0; i -- )
{
sig[i] = aparicion[C[i]];
aparicion[C[i]] = i;
}
for( int i = 0; i < K; i ++ )
{
activo[i] = true;
q.push( { i , aparicion[i] } );
}
for( int i = 0; i < N; i ++ )
{
int val = C[i];
if( activo[val] )
empuja( val );
else
{
nodo act = q.top();
activo[act.v] = false;
q.pop();
empuja( act.v );
q.push( { val , sig[i] } );
activo[val] = true;
}
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
int numbits = ( int ) ceil( log2( N ) );
int idx = numbits - 1;
for( int i = 0; i < N; i ++ )
{
int color = GetRequest( );
int quita = 0;
for( int j = 0; j < numbits; j ++ )
if( A[idx - j] == 1 )
quita += ( 1 << j );
if( quita != color )
PutBack( quita );
idx += numbits;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
736 KB |
Output is correct |
2 |
Incorrect |
4 ms |
976 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
2312 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
318 ms |
12672 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
12672 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
404 ms |
15520 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
432 ms |
15520 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
421 ms |
15520 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
411 ms |
15768 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
461 ms |
15768 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
534 ms |
15912 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
481 ms |
15912 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
419 ms |
15912 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
414 ms |
15912 KB |
Output isn't correct - not an optimal way |
10 |
Partially correct |
440 ms |
15912 KB |
Output is partially correct - 1700000 bits used |