Cod sursa(job #441849)

Utilizator alexandru92alexandru alexandru92 Data 13 aprilie 2010 16:08:12
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.05 kb
/* 
 * File:   main.cpp
 * Author: VirtualDemon
 *
 * Created on April 12, 2010, 4:23 PM
 */
#include <cstdlib>
#include <fstream>
#include <tr1/unordered_set>
#define SIZE 8219

/*
 *
 */
using namespace std;
using namespace tr1;
ifstream in;
int ifile;
char file[SIZE];
unordered_set< int > s;
inline void read( int& x )
{
    x=0;
    while( file[ifile] < '0' || file[ifile] > '9' )
        if( ++ifile == SIZE )
        {
            in.read( file, SIZE );
            ifile=0;
        }
    while( file[ifile] >= '0' && file[ifile] <= '9' )
    {
        x=x*10+file[ifile]-'0';
        if( ++ifile == SIZE )
        {
            in.read( file, SIZE );
            ifile=0;
        }
    }
}
int main( void )
{
    int N, i, j;
    in.open( "hashuri.in" );
    ofstream out( "hashuri.out" );
    read(N);
    for( ; N; --N )
    {
        read(i); read(j);
        switch(i)
        {
            case 1 : s.insert(j); break;
            case 2 : s.erase(j); break;
            case 3 : out<<( s.end() != s.find(j) )<<'\n';
        }
    }
    return EXIT_SUCCESS;
}