Cod sursa(job #568032)

Utilizator raica_cristiraica dumitru cristian raica_cristi Data 30 martie 2011 19:00:51
Problema Heapuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.05 kb
#include <stdio.h>
#include <queue>
#include <vector>
#include <bitset>

using namespace std ;
#define dim 200100
#define mp make_pair
#define fs first
#define sc second
bitset <dim > viz ;
int c;
struct cmp
{
    bool operator() ( const pair <int,int> &a , const pair <int , int  > &b  ) const
    {
        return a>b;
    }
};
priority_queue <pair <int , int > , vector < pair < int , int > > , cmp > q;

void solve ()
{

    int n,y,x;
    scanf("%d",&n);
    for(int i=1 ; i<=n;i++)
    {
        scanf("%d",&y ) ;
        if ( y == 1 )
        {
            scanf("%d",&x);
            q.push(mp (x, ++c ));
           // viz[x] = 0;
        }
        if ( y==2 )
        {
            scanf("%d",&x ) ;
            viz[x] = 1;
        }
        if ( y==3 )
        {
            while ( viz [ q.top().sc ] == 1 )
            q.pop();
            printf("%d\n",q.top().fs );
        }
    }
}
int main ()
{
    freopen("heapuri.in","r",stdin);
    freopen("heapuri.out","w",stdout);
    solve () ;

    return 0;
}