Submission #51980

# Submission time Handle Problem Language Result Execution time Memory
51980 2018-06-22T21:17:00 Z diegogrc Last supper (IOI12_supper) C++17
Compilation error
0 ms 0 KB
#include "advisor.h"

#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"

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;
    }

}

Compilation message

advisor.cpp:19:1: error: 'priority_queue' does not name a type
 priority_queue < nodo > q;
 ^~~~~~~~~~~~~~
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:33:29: error: 'log2' was not declared in this scope
     maxbits = ( int ) ceil( log2( N ) );
                             ^~~~
advisor.cpp:33:29: note: suggested alternative: 'long'
     maxbits = ( int ) ceil( log2( N ) );
                             ^~~~
                             long
advisor.cpp:33:23: error: 'ceil' was not declared in this scope
     maxbits = ( int ) ceil( log2( N ) );
                       ^~~~
advisor.cpp:44:9: error: 'q' was not declared in this scope
         q.push( { i , aparicion[i] } );
         ^
advisor.cpp:53:24: error: 'q' was not declared in this scope
             nodo act = q.top();
                        ^

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:4:33: error: 'log2' was not declared in this scope
     int numbits = ( int ) ceil( log2( N ) );    
                                 ^~~~
assistant.cpp:4:33: note: suggested alternative: 'long'
     int numbits = ( int ) ceil( log2( N ) );    
                                 ^~~~
                                 long
assistant.cpp:4:27: error: 'ceil' was not declared in this scope
     int numbits = ( int ) ceil( log2( N ) );    
                           ^~~~