Cod sursa(job #1321250)

Utilizator YusukeFMI Mares Medar Razvan Yusuke Data 18 ianuarie 2015 21:56:44
Problema Hashuri Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.69 kb
#include <fstream>
#include <list>
#define NRM 500009
using namespace std;
ifstream f("hashuri.in");
ofstream g("hashuri.out");
long N, tip, x, m, ex, i;
list<long> lista[NRM];
list<long>::iterator it;

int main()
{
    f >> N;
    for( i=1; i <= N ; i++){
        f >> tip >> x;
        m = x % NRM;
        ex=0;
        for(it = lista[m].begin();it != lista[m].end(); it++ ){
            if((*it)==x){
                if(tip == 2)
                    lista[m].erase( it );
                ex = *it;
                break;
            }
        }
        if( tip == 1 && !ex)
            lista[m].push_back(x);
        if( tip == 3)
            g << (ex!=0) << '\n';
    }
}