Submission #51987

# Submission time Handle Problem Language Result Execution time Memory
51987 2018-06-22T22:02:57 Z diegogrc Last supper (IOI12_supper) C++17
34 / 100
430 ms 16600 KB
#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 
    {
        if( a.p != p )
            return a.p > p;
        return a.v < v;
    }
};
bool activo[MAX];
int aparicion[MAX];
int sig[MAX]; 
int posde[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( K ) );
    for( int i = 0; i < N; i ++ )
    {
        aparicion[i] = INF;
        posde[i] = INF;
    }
    for( int i = N-1; i >= 0; i -- )
    {
        int val = C[i];
        sig[i] = aparicion[val];
        aparicion[val] = i;
    }
    for( int i = 0; i < K; i ++ )
    {
        posde[i] = i;
        activo[i] = true;
        q.push( { i , aparicion[i] } );
    }
    for( int i = 0; i < N; i ++ )
    {
        int val = C[i];
        if( activo[val] )
        {
            empuja( posde[val] );
            q.push( { val , sig[i] } );
        }
        else
        {
            while( q.top().p < i )
                q.pop();
            nodo act = q.top();
            activo[act.v] = false;
            posde[val] = posde[act.v];
            posde[act.v] = INF;
            q.pop();
            empuja( posde[val] );
            q.push( { val , sig[i] } );
            activo[val] = true;
        }
    }
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define INF 1e9



int posi[MAX];
int estado[MAX];

void Assist(unsigned char *A, int N, int K, int R) {
    int numbits = ( int ) ceil( log2( K ) );    
    int idx = numbits - 1;
    for( int i = 0; i < N; i ++ )
        posi[i] = INF;
    for( int i = 0; i < K; i ++ )
    {
        posi[i] = i;
        estado[i] = i;
    }
    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( posi[color] != quita )
        {
            PutBack( estado[quita] );
            posi[estado[quita]] = INF;
            posi[color] = quita;
            estado[quita] = color;
        }
        idx += numbits;
    }

}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 868 KB Output is correct
2 Correct 4 ms 984 KB Output is correct
3 Correct 8 ms 1356 KB Output is correct
4 Correct 8 ms 1384 KB Output is correct
5 Correct 8 ms 1516 KB Output is correct
6 Correct 15 ms 1560 KB Output is correct
7 Correct 20 ms 1840 KB Output is correct
8 Correct 19 ms 1872 KB Output is correct
9 Correct 22 ms 1872 KB Output is correct
10 Correct 23 ms 2144 KB Output is correct
11 Correct 18 ms 2144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2656 KB Output is correct
2 Correct 162 ms 7800 KB Output is correct
3 Correct 430 ms 16600 KB Output is correct
4 Correct 165 ms 16600 KB Output is correct
5 Correct 248 ms 16600 KB Output is correct
6 Correct 308 ms 16600 KB Output is correct
7 Correct 357 ms 16600 KB Output is correct
8 Correct 302 ms 16600 KB Output is correct
9 Correct 124 ms 16600 KB Output is correct
10 Correct 378 ms 16600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 315 ms 16600 KB Output is correct
2 Correct 360 ms 16600 KB Output is correct
3 Correct 380 ms 16600 KB Output is correct
4 Correct 349 ms 16600 KB Output is correct
5 Correct 343 ms 16600 KB Output is correct
6 Correct 358 ms 16600 KB Output is correct
7 Correct 363 ms 16600 KB Output is correct
8 Correct 424 ms 16600 KB Output is correct
9 Correct 349 ms 16600 KB Output is correct
10 Correct 359 ms 16600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 16600 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 361 ms 16600 KB Output is partially correct - 1500000 bits used
2 Partially correct 371 ms 16600 KB Output is partially correct - 1500000 bits used
3 Partially correct 413 ms 16600 KB Output is partially correct - 1500000 bits used
4 Partially correct 357 ms 16600 KB Output is partially correct - 1500000 bits used
5 Partially correct 350 ms 16600 KB Output is partially correct - 1500000 bits used
6 Partially correct 355 ms 16600 KB Output is partially correct - 1500000 bits used
7 Partially correct 350 ms 16600 KB Output is partially correct - 1497585 bits used
8 Partially correct 356 ms 16600 KB Output is partially correct - 1500000 bits used
9 Partially correct 352 ms 16600 KB Output is partially correct - 1500000 bits used
10 Partially correct 353 ms 16600 KB Output is partially correct - 1500000 bits used